Comments (14)
$ cabal v1-test --test-options=--test-seed=-8336481659523868200
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
[__0] trying: Diff-0.5 (user goal)
[__1] unknown package: test-framework-quickcheck2 (dependency of Diff)
[__1] fail (backjumping, conflict set: Diff, test-framework-quickcheck2)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: Diff, test-framework-quickcheck2
Trying configure anyway.
Configuring Diff-0.5...
cabal: Encountered missing dependencies:
test-framework -any, test-framework-quickcheck2 -any
from diff.
The simplest way to reproduce would be
diff --git a/test/Test.hs b/test/Test.hs
index e725805..d357147 100644
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -38,6 +38,9 @@ main = defaultMain [ testGroup "sub props" [
testProperty "self generates empty" $ forAll shortLists prop_ppDiffEqual,
--testProperty "compare our lists with diff" $ forAll2 shortLists prop_ppDiffShort,
testProperty "compare random with diff" prop_ppDiffR,
+ testProperty "compare with diff, issue #5" $ prop_ppDiffR
+ (DiffInput {diLeft = ["1","2","3","4","","5","6","7"], diRight = ["1","2","3","q","b","u","l","","XXX6",""]}),
testProperty "test parse" prop_parse,
testProperty "test context" prop_context_diff
]
But it succeeds on my machine even in this form.
The test compare Haskell output against system diff
tool. @alaendle what's the output of diff --version
on your machine?
$ diff --version
Apple diff (based on FreeBSD diff)
from diff.
And on my machine it's
OUT:
4c4,7
< 4
---
> q
> b
> u
> l
6,8c9,10
< 5
< 6
< 7
---
> XXX6
>
ERR:
ECODE:
ExitFailure 1
compare with diff, issue #5: [OK, passed 1 tests]
So different implementations of diff
choose different edit scripts of the same length, which is fine. This is not a bug per se, just a bogus test.
from diff.
I suppose a better test would be a round trip where you use Diff to make a patch and use the unix patch utility to apply it to the second argument and obtain the first.
from diff.
Could you explain how to provide these arguments to the test suite?
from diff.
Nothing easier than that:
cabal test --test-options=--test-seed=-8336481659523868200
(fyi @ddssff )
from diff.
I'm having trouble reproducing this error, though I'm not 100% convinced that the test seed is being set. On my system cabal test does not work, only cabal new-test, due to some dependency errors. And cabal new-test does not accept the test-options flag. Could you tell me more about what environment you are running this in?
from diff.
Ok, cabal install was able to install after I updated. But I'm not getting the failure:
Running 1 test suites...
Test suite diff-tests: RUNNING...
dist/build/diff-tests/diff-tests '--test-seed=-8336481659523868200'
Test suite diff-tests: PASS
Test suite logged to: dist/test/Diff-0.5-diff-tests.log
1 of 1 test suites (1 of 1 test cases) passed.
from diff.
Strange that you couldn't reproduce it - here my cabal.project.freeze
- using cabal-3.6.2.0 and ghc-9.4.7.
active-repositories: hackage.haskell.org:merge
constraints: any.QuickCheck ==2.14.3,
QuickCheck -old-random +templatehaskell,
any.ansi-terminal ==1.0,
ansi-terminal -example,
any.ansi-terminal-types ==0.11.5,
any.ansi-wl-pprint ==1.0.2,
ansi-wl-pprint -example,
any.array ==0.5.4.0,
any.base ==4.17.2.0,
any.binary ==0.8.9.1,
any.bytestring ==0.11.5.2,
any.colour ==2.3.6,
any.containers ==0.6.7,
any.deepseq ==1.4.8.0,
any.directory ==1.3.7.1,
any.extensible-exceptions ==0.1.1.4,
any.filepath ==1.4.2.2,
any.ghc-bignum ==1.3,
any.ghc-boot-th ==9.4.7,
any.ghc-prim ==0.9.1,
any.hostname ==1.0,
any.mtl ==2.2.2,
any.old-locale ==1.0.0.7,
any.pretty ==1.1.3.6,
any.prettyprinter ==1.7.1,
prettyprinter -buildreadme +text,
any.prettyprinter-ansi-terminal ==1.1.3,
any.prettyprinter-compat-ansi-wl-pprint ==1.0.2,
any.process ==1.6.17.0,
any.random ==1.2.1.1,
any.regex-base ==0.94.0.2,
any.regex-posix ==0.96.0.1,
regex-posix -_regex-posix-clib,
any.rts ==1.0.2,
any.splitmix ==0.1.0.5,
splitmix -optimised-mixer,
any.template-haskell ==2.19.0.0,
any.test-framework ==0.8.2.0,
any.test-framework-quickcheck2 ==0.3.0.5,
any.text ==2.0.2,
any.time ==1.12.2,
any.transformers ==0.5.6.2,
any.unix ==2.7.3,
any.xml ==1.3.14
index-state: hackage.haskell.org 2023-10-13T17:18:34Z
This leads to
@alaendle ➜ /workspaces/Diff (master) $ cabal test --test-options=--test-seed=-8336481659523868200
Build profile: -w ghc-9.4.7 -O1
In order, the following will be built (use -v for more details):
- Diff-0.5 (test:diff-tests) (first run)
Preprocessing test suite 'diff-tests' for Diff-0.5..
Building test suite 'diff-tests' for Diff-0.5..
Running 1 test suites...
Test suite diff-tests: RUNNING...
sub props:
empty in subs: [OK, passed 100 tests]
self in subs: [OK, passed 100 tests]
count subs: [OK, passed 100 tests]
every sub is a sub: [OK, passed 100 tests]
sub prop: [OK, passed 100 tests]
diff props:
lcsEmpty: [OK, passed 100 tests]
lcsSelf: [OK, passed 100 tests]
lcsBoth: [OK, passed 100 tests]
recover first: [OK, passed 100 tests]
recover second: [OK, passed 100 tests]
lcs: [OK, passed 100 tests]
output props:
self generates empty: [OK, passed 100 tests]
compare random with diff: [Failed]
*** Failed! Falsified (after 87 tests):
DiffInput {diLeft = ["1","2","3","4","","5","6","7"], diRight = ["1","2","3","q","b","u","l","","XXX6",""]}
(used seed -8336481659523868200)
test parse: [OK, passed 100 tests]
test context: [OK, passed 1 tests]
Properties Total
Passed 14 14
Failed 1 1
Total 15 15
Test suite diff-tests: FAIL
Test suite logged to:
/workspaces/Diff/dist-newstyle/build/x86_64-linux/ghc-9.4.7/Diff-0.5/t/diff-tests/test/Diff-0.5-diff-tests.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:diff-tests from Diff-0.5.
But in any case, thank you very much for looking at it so closely.
from diff.
Originally occurred on the stackage build server with
diff --version
diff (GNU diffutils) 3.7
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Paul Eggert, Mike Haertel, David Hayes,
Richard Stallman, and Len Tower.
But also reproduced on my local machine which has a slightly newer version.
diff --version
diff (GNU diffutils) 3.8
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Paul Eggert, Mike Haertel, David Hayes,
Richard Stallman, and Len Tower.
If I enable the putStrLn
in in Test.hs
it shows:
OUT:
4c4,9
< 4
---
> q
> b
> u
> l
>
> XXX6
6,8d10
< 5
< 6
< 7
ERR:
ECODE:
ExitFailure 1
compare with diff, issue #5: [Failed]
from diff.
It appears that the failure is due to different grouping between the haskell implementation and the OS utility:
*Main Test.QuickCheck.Property> let le = ["'1'","'2'","'3'","'4'","' '","'5'","'6'","'7'"]
*Main Test.QuickCheck.Property> let ri = ["'1'","'2'","'3'","'q'","'b'","'u'","'l'","' '","'XXX6'","' '"]
*Main Test.QuickCheck.Property> let haskDiff = ppDiff $ getGroupedDiff le ri
*Main Test.QuickCheck.Property> let utilDiff= unsafePerformIO (runDiff (unlines le) (unlines ri))
*Main Test.QuickCheck.Property> haskDiff
"4c4,7\n< '4'\n---\n> 'q'\n> 'b'\n> 'u'\n> 'l'\n6,8c9,10\n< '5'\n< '6'\n< '7'\n---\n> 'XXX6'\n> ' '\n"
*Main Test.QuickCheck.Property> utilDiff
"4c4,9\n< '4'\n---\n> 'q'\n> 'b'\n> 'u'\n> 'l'\n> ' '\n> 'XXX6'\n6,8d10\n< '5'\n< '6'\n< '7'\n"
*Main Test.QuickCheck.Property> putStrLn haskDiff
4c4,7
< '4'
---
> 'q'
> 'b'
> 'u'
> 'l'
6,8c9,10
< '5'
< '6'
< '7'
---
> 'XXX6'
> ' '
*Main Test.QuickCheck.Property> putStrLn utilDiff
4c4,9
< '4'
---
> 'q'
> 'b'
> 'u'
> 'l'
> ' '
> 'XXX6'
6,8d10
< '5'
< '6'
< '7'
from diff.
@Bodigrim any thoughts on this? I'm not sure what metrics are involved in choosing which grouping is correct.
from diff.
Sorry I missed comments from @Bodigrim and @alaendle before posting my own - I'm not used to people paying attention to this repo!
from diff.
One thing which is off with the test is this:
Line 141 in 8799435
We should not really compare the length of outputs in bytes, only number of lines. Let me try to make it more robust.
from diff.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diff.