Skip to content

Commit

Permalink
Remove the baseline test new-year race condition. Fix #3723. (#3724)
Browse files Browse the repository at this point in the history
* Patch the baseline test new-year race condition. Fix #3723.

* Use freezegun to circumvent the new year race condition.
  • Loading branch information
aknrdureegaesr authored Feb 22, 2025
1 parent ac1fcd5 commit 978bb1d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
tmp/
cache/
output/
baseline/
nikola-baseline-build/
/tags
v3.*.zip.*

# GitHub token
.pypt/gh-token
Expand Down
22 changes: 11 additions & 11 deletions nikola/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ def main(args=None):
else:
needs_config_file = False

invariant = False

if len(args) > 0 and args[0] == 'build' and '--invariant' in args:
try:
import freezegun
freeze = freezegun.freeze_time("2038-01-01")
freeze.start()
invariant = True
except ImportError:
req_missing(['freezegun'], 'perform invariant builds')

sys.path.insert(0, os.path.dirname(conf_filename))
try:
spec = importlib.util.spec_from_file_location("conf", conf_filename)
Expand All @@ -138,17 +149,6 @@ def main(args=None):
if conf_filename_changed:
LOGGER.info("Using config file '{0}'".format(conf_filename))

invariant = False

if len(args) > 0 and args[0] == 'build' and '--invariant' in args:
try:
import freezegun
freeze = freezegun.freeze_time("2038-01-01")
freeze.start()
invariant = True
except ImportError:
req_missing(['freezegun'], 'perform invariant builds')

if config:
if os.path.isdir('plugins') and not os.path.exists('plugins/__init__.py'):
with open('plugins/__init__.py', 'w') as fh:
Expand Down
6 changes: 4 additions & 2 deletions scripts/baseline.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash

set -e -o pipefail -x

PYVER=$(scripts/getpyver.py short)
if [[ "$1" == "check" ]]; then
echo -e "\033[36m>> Downloading baseline for $PYVER...\033[0m"
Expand All @@ -19,8 +22,7 @@ rm "pages/creating-a-theme.rst" "pages/extending.rst" "pages/internals.rst" "pag
LC_ALL='en_US.UTF-8' PYTHONHASHSEED=0 nikola build --invariant
if [[ "$1" == "check" ]]; then
echo -e "\033[36m>> Testing baseline...\033[0m"
diff -ubwr ../baseline output
if [[ $? == 0 ]]; then
if diff -ubwr ../baseline output; then
echo -e "\033[32;1m>> Baseline test successful\033[0m"
else
CODE=$?
Expand Down

0 comments on commit 978bb1d

Please sign in to comment.