-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Canonify outputs when updating baselines via btest-diff
This leverages the same canonicalization btest-diff already applies during test output comparison against baselines also when updating those baselines (usually via btest -U/-u). This removes a bunch of noise from the baselines, including personal home directories, timestamps, etc. Since btest-diff doesn't know whether the baseline has undergone this canonicalization, it continues to canonicalize the basline prior to diffing. To track whether it has canonicalized a baseline when updating, btest-diff now also prepends a header to the generated baseline that warns users about the fact that it is auto-generated. The presence of this header doubles as a marker for canonicalization. Includes a test-case.
- Loading branch information
Showing
2 changed files
with
114 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# This test verifies that we only canonicalize baselines once, namely | ||
# when canonicalizing new test output, and that baselines get | ||
# converted over to our header-tagged format. | ||
# | ||
# Test prep: make our canonifier executable | ||
# %TEST-EXEC: chmod 755 ./diff-double-x | ||
# | ||
# Test prep: create a "dated" baseline. | ||
# %TEST-EXEC: mkdir -p Baseline/canonifier-conversion | ||
# %TEST-EXEC: echo x >Baseline/canonifier-conversion/output | ||
# | ||
# Verify that it succeeds: | ||
# %TEST-EXEC: btest %INPUT | ||
# | ||
# Update the baseline. This should prefix btest-diff's header and canonify: | ||
# %TEST-EXEC: btest -U %INPUT | ||
# | ||
# Verify that these have happened and preserve baseline: | ||
# %TEST-EXEC: head -1 Baseline/canonifier-conversion/output | grep -q 'Do not edit' | ||
# %TEST-EXEC: tail -1 Baseline/canonifier-conversion/output | grep xx | ||
# %TEST-EXEC: cp Baseline/canonifier-conversion/output base.1 | ||
# | ||
# Verify that it still succeeds: | ||
# %TEST-EXEC: btest %INPUT | ||
# | ||
# Update the baseline again. | ||
# %TEST-EXEC: btest -U %INPUT | ||
# %TEST-EXEC: cp Baseline/canonifier-conversion/output base.2 | ||
# | ||
# Verify the updated baselines remained identical. | ||
# %TEST-EXEC: test "$(cat base.1)" = "$(cat base.2)" | ||
|
||
@TEST-EXEC: echo x >output | ||
@TEST-EXEC: btest-diff output | ||
|
||
%TEST-START-FILE btest.cfg | ||
[btest] | ||
TmpDir = .tmp | ||
|
||
[environment] | ||
TEST_DIFF_CANONIFIER=%(testbase)s/diff-double-x | ||
%TEST-END-FILE | ||
|
||
%TEST-START-FILE diff-double-x | ||
#! /usr/bin/env bash | ||
sed 's/x/xx/g' | ||
%TEST-END-FILE |