From 1f387912afd65f941b9c3dcba492c0f60f3c0c6e Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Fri, 26 Feb 2021 09:45:59 +0000 Subject: [PATCH] testscript: add test to show cmp with small diff between large files Also define $ as part of the standard testscript environment, for use in cmpenv situations where the literal $ is required in a file. --- testscript/testdata/long_diff.txt | 167 ++++++++++++++++++++++++++++++ testscript/testscript.go | 1 + 2 files changed, 168 insertions(+) create mode 100644 testscript/testdata/long_diff.txt diff --git a/testscript/testdata/long_diff.txt b/testscript/testdata/long_diff.txt new file mode 100644 index 00000000..431ab8eb --- /dev/null +++ b/testscript/testdata/long_diff.txt @@ -0,0 +1,167 @@ +# Verify the behaviour of cmp in the case of a small diff between +# two large files + +unquote dir/script.txt +! testscript dir +env +cmpenv stdout stdout.golden + +-- dir/script.txt -- +>cmp a b +> +>-- a -- +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>-- b -- +>b +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +>a +-- stdout.golden -- + +> cmp a b +[diff -a +b] +-a ++b + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + +FAIL: $$WORK${/}dir${/}script.txt:1: a and b differ diff --git a/testscript/testscript.go b/testscript/testscript.go index 495a6e0a..75a6c9a6 100644 --- a/testscript/testscript.go +++ b/testscript/testscript.go @@ -299,6 +299,7 @@ func (ts *TestScript) setup() string { "devnull=" + os.DevNull, "/=" + string(os.PathSeparator), ":=" + string(os.PathListSeparator), + "$=$", // If we are collecting coverage profiles for merging into the main one, // ensure the environment variable is forwarded to sub-processes.