Skip to content

Commit 1108438

Browse files
Patch the baseline test new-year race condition. Fix #3723.
1 parent 8689cf3 commit 1108438

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

.gitignore

+3
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

scripts/baseline.sh

+35-2
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,38 @@ 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+
python3 -c '
26+
# In-place edit of copyright notes to adjust the copyright year.
27+
import time
28+
YEAR = str(time.gmtime().tm_year)
29+
for edit_me in [
30+
"../baseline/rss.xml",
31+
"../baseline/index.html",
32+
"../baseline/galleries/index.html",
33+
"../baseline/galleries/demo/index.html",
34+
"../baseline/listings/index.html",
35+
"../baseline/listings/hello.py.html",
36+
"../baseline/listings/__pycache__/index.html",
37+
"../baseline/pages/about-nikola/index.html",
38+
"../baseline/pages/bootstrap-demo/index.html",
39+
"../baseline/pages/dr-nikolas-vendetta/index.html",
40+
"../baseline/pages/listings-demo/index.html",
41+
"../baseline/pages/quickref/index.html",
42+
"../baseline/pages/quickstart/index.html",
43+
"../baseline/posts/welcome-to-nikola/index.html",
44+
]:
45+
with open(edit_me, "rt+") as rssf:
46+
rss = rssf.read()
47+
copyright_prelude = "Contents © "
48+
copyright_prelude_position = rss.find(copyright_prelude)
49+
if -1 == copyright_prelude_position:
50+
raise RuntimeError(f"Could not find copyright note in {edit_me}")
51+
copyright_position = copyright_prelude_position + len(copyright_prelude)
52+
new_rss = rss[:copyright_position] + YEAR + rss[copyright_position+4:]
53+
rssf.seek(0, 0)
54+
rssf.write(new_rss)
55+
'
56+
if diff -ubwr ../baseline output; then
2457
echo -e "\033[32;1m>> Baseline test successful\033[0m"
2558
else
2659
CODE=$?

0 commit comments

Comments
 (0)