Skip to content

Commit 263f674

Browse files
committed
Ignore logs trailing whitespace diff in integration test
The table package used to format Arduino Lint output fills out the full column width with trailing whitespace. The generated and golden master logs contain mutable strings of different length which are replaced before comparing them in the integration tests. The resulting mismatch will cause a spurious integration test failure. The solution is to strip the trailing whitespace before doing the comparison.
1 parent 9b39d12 commit 263f674

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: test/test_all.py

+9
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@ def check_logs(configuration, golden_logs_parent_path, logs_subpath):
148148
logs_subpath -- sub-path for both the actual and golden master logs
149149
"""
150150
logs = pathlib.Path(configuration["LogsFolder"], logs_subpath).read_text(encoding="utf-8")
151+
# The table package used to format Arduino Lint output fills out the full column width with trailing whitespace.
152+
# This might not match the golden master logs after the template substitution.
153+
logs = "\n".join([line.rstrip() for line in logs.splitlines()])
151154

152155
golden_logs_template = golden_logs_parent_path.joinpath(logs_subpath).read_text(encoding="utf-8")
156+
golden_logs_template = "\n".join([line.rstrip() for line in golden_logs_template.splitlines()])
153157
# Fill template with mutable content
154158
golden_logs = string.Template(template=golden_logs_template).substitute(
155159
git_clones_folder=configuration["GitClonesFolder"]
@@ -179,6 +183,9 @@ def check_db(configuration):
179183
# The checksum values in the db will be different on every run, so it's necessary to replace them with a
180184
# placeholder before comparing to the golden master
181185
release["Checksum"] = checksum_placeholder
186+
# The table package used to format Arduino Lint output fills out the full column width with trailing whitespace.
187+
# This might not match the golden master release's "Log" field after the template substitution.
188+
release["Log"] = "\n".join([line.rstrip() for line in release["Log"].splitlines()])
182189

183190
# Load golden index
184191
golden_db_template = test_data_path.joinpath("test_all", "golden", "db.json").read_text(encoding="utf-8")
@@ -189,6 +196,8 @@ def check_db(configuration):
189196
git_clones_folder=configuration["GitClonesFolder"],
190197
)
191198
golden_db = json.loads(golden_db_string)
199+
for release in golden_db["Releases"]:
200+
release["Log"] = "\n".join([line.rstrip() for line in release["Log"].splitlines()])
192201

193202
# Compare db against golden master
194203
# Order of entries in the db is arbitrary so a simply equality assertion is not possible

0 commit comments

Comments
 (0)