Skip to content

Commit

Permalink
testscript: add test to show cmp with small diff between large files (#…
Browse files Browse the repository at this point in the history
…129)

Also define $ as part of the standard testscript environment, for use in
cmpenv situations where the literal $ is required in a file.
  • Loading branch information
myitcv committed Mar 1, 2021
1 parent 1e247e4 commit 45d8df8
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 0 deletions.
167 changes: 167 additions & 0 deletions 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
1 change: 1 addition & 0 deletions testscript/testscript.go
Expand Up @@ -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.
Expand Down

0 comments on commit 45d8df8

Please sign in to comment.