Skip to content

Commit 978bb1d

Browse files
Remove the baseline test new-year race condition. Fix getnikola#3723. (getnikola#3724)
* Patch the baseline test new-year race condition. Fix getnikola#3723. * Use freezegun to circumvent the new year race condition.
1 parent ac1fcd5 commit 978bb1d

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
tmp/
66
cache/
77
output/
8+
baseline/
9+
nikola-baseline-build/
810
/tags
11+
v3.*.zip.*
912

1013
# GitHub token
1114
.pypt/gh-token

nikola/__main__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ def main(args=None):
116116
else:
117117
needs_config_file = False
118118

119+
invariant = False
120+
121+
if len(args) > 0 and args[0] == 'build' and '--invariant' in args:
122+
try:
123+
import freezegun
124+
freeze = freezegun.freeze_time("2038-01-01")
125+
freeze.start()
126+
invariant = True
127+
except ImportError:
128+
req_missing(['freezegun'], 'perform invariant builds')
129+
119130
sys.path.insert(0, os.path.dirname(conf_filename))
120131
try:
121132
spec = importlib.util.spec_from_file_location("conf", conf_filename)
@@ -138,17 +149,6 @@ def main(args=None):
138149
if conf_filename_changed:
139150
LOGGER.info("Using config file '{0}'".format(conf_filename))
140151

141-
invariant = False
142-
143-
if len(args) > 0 and args[0] == 'build' and '--invariant' in args:
144-
try:
145-
import freezegun
146-
freeze = freezegun.freeze_time("2038-01-01")
147-
freeze.start()
148-
invariant = True
149-
except ImportError:
150-
req_missing(['freezegun'], 'perform invariant builds')
151-
152152
if config:
153153
if os.path.isdir('plugins') and not os.path.exists('plugins/__init__.py'):
154154
with open('plugins/__init__.py', 'w') as fh:

scripts/baseline.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
3+
set -e -o pipefail -x
4+
25
PYVER=$(scripts/getpyver.py short)
36
if [[ "$1" == "check" ]]; then
47
echo -e "\033[36m>> Downloading baseline for $PYVER...\033[0m"
@@ -19,8 +22,7 @@ rm "pages/creating-a-theme.rst" "pages/extending.rst" "pages/internals.rst" "pag
1922
LC_ALL='en_US.UTF-8' PYTHONHASHSEED=0 nikola build --invariant
2023
if [[ "$1" == "check" ]]; then
2124
echo -e "\033[36m>> Testing baseline...\033[0m"
22-
diff -ubwr ../baseline output
23-
if [[ $? == 0 ]]; then
25+
if diff -ubwr ../baseline output; then
2426
echo -e "\033[32;1m>> Baseline test successful\033[0m"
2527
else
2628
CODE=$?

0 commit comments

Comments
 (0)