on master help sign in
Compare failing logs with exact expected result

This will allow us to test on more code and catch changes in the logs as they happen.

commit31f6cfd83f5ddb35746b085c8b219625bcf82113 authorMark Karpov <markkarpov92@gmail.com> dateTue 14 Apr 2020, 20:30 (7 years ago) parent9874ac7
18 files changed+318−67
app/Main.hs+1−2 default.nix+34−38 expected-failures/Agda.txt+35 expected-failures/aws.txt+10 expected-failures/brick.txt+6 expected-failures/distributed-process.txt+8 expected-failures/esqueleto.txt+8 expected-failures/fay.txt+19 expected-failures/idris.txt+102 expected-failures/intero.txt+6 expected-failures/leksah.txt+12 expected-failures/lens.txt+4 expected-failures/pandoc.txt+16 expected-failures/pipes.txt+4 expected-failures/purescript.txt+19 expected-failures/stack.txt+6 nix/ormolize/default.nix+28−10 nix/ormolize/ormolize.sh−17
app/Main.hs+1−2
@@ -37,9 +37,8 @@ main = withPrettyOrmoluExceptions $ do
3737 -- It is possible to get IOException, error's and 'OrmoluException's
3838 -- from 'formatOne', so we just catch everything.
3939 errs <-
40− lefts <$> mapM (try @SomeException . formatOne' . Just) xs
40+ lefts <$> mapM (try @SomeException . formatOne' . Just) (sort xs)
4141 unless (null errs) $ do
42− hPutStrLn stderr "Some files failed to format:\n"
4342 mapM_ (hPutStrLn stderr . displayException) errs
4443 exitWith (ExitFailure 102)
4544
default.nix+34−38
@@ -27,24 +27,30 @@ let
2727 inherit pkgs;
2828 inherit haskellPackages;
2929 };
30− # NOTE We have to exclude some directories for some packages because
31− # Ormolu needs files to be parsable by Haddock which is not always the
32− # case. For example some tests and examples do not parse.
33− excludedHackageDirs = {
34− "aws" = ["Examples"];
35− "distributed-process" = ["benchmarks"];
36− "esqueleto" = ["test"];
37− "fay" = ["examples"];
38− "postgrest" = ["test"];
39− };
30+ expectedFailures = [
31+ "Agda"
32+ "aws"
33+ "brick"
34+ "distributed-process"
35+ "esqueleto"
36+ "fay"
37+ "idris"
38+ "intero"
39+ "leksah"
40+ "lens"
41+ "pandoc"
42+ "pipes"
43+ "purescript"
44+ "stack"
45+ ];
4046 ormolizedPackages = doCheck:
4147 pkgs.lib.mapAttrs (name: p: ormolize {
4248 package = p;
4349 inherit doCheck;
44− excludedDirs =
45− if builtins.hasAttr name excludedHackageDirs
46− then excludedHackageDirs.${name}
47− else [];
50+ expectedFailures =
51+ if pkgs.lib.lists.any (x: x == name) expectedFailures
52+ then ./expected-failures + "/${name}.txt"
53+ else null;
4854 }) haskellPackages;
4955in {
5056 ormolu = haskellPackages.ormolu;
@@ -74,55 +80,45 @@ in {
7480 hackage = ormolizedPackages false;
7581 hackageTests = with pkgs.lib; pkgs.recurseIntoAttrs (
7682 let ps = [
83+ "Agda"
7784 "QuickCheck"
7885 "ShellCheck"
7986 "aeson"
8087 "attoparsec"
8188 "aws"
89+ "brick"
8290 "capability"
8391 "cassava"
8492 "conduit"
8593 "cryptonite"
8694 "diagrams-core"
8795 "distributed-process"
96+ "esqueleto"
8897 "fay"
8998 "hakyll"
9099 "haxl"
91100 "hedgehog"
101+ "hledger"
92102 "hlint"
103+ "http-client"
104+ "idris"
105+ "intero"
106+ "leksah"
107+ "lens"
93108 "megaparsec"
94− "ormolu"
95109 "optics"
110+ "ormolu"
111+ "pandoc"
112+ "pipes"
96113 "postgrest"
114+ "purescript"
97115 "servant"
98116 "servant-server"
117+ "stack"
99118 "tensorflow"
100119 "text_1_2_4_0"
101120 "tls"
102121 "yesod-core"
103−
104− # Uses CPP to concatenate strings in a deprecation annotation
105−
106− # "esqueleto"
107−
108− # Comment idempotence issue
109−
110− # "Agda"
111− # "brick"
112− # "hledger"
113− # "http-client"
114− # "idris"
115− # "intero"
116− # "leksah"
117− # "pandoc"
118− # "pipes"
119− # "stack"
120−
121− # Missing language extension
122−
123− # "lens" #fixed in master
124− # "purescript"
125−
126122 ];
127123 in listToAttrs (map (p: nameValuePair p (ormolizedPackages true).${p}) ps)
128124 );
expected-failures/Agda.txtnew file+35
@@ -0,0 +1,35 @@
1+Formatting is not idempotent:
2+ src/full/Agda/Auto/CaseSplit.hs<rendered>:176:54
3+ before: ", pats') = applyperm"
4+ after: ", pats') =\n "
5+Please, consider reporting the bug.
6+
7+Formatting is not idempotent:
8+ src/full/Agda/Syntax/Internal.hs<rendered>:236:12
9+ before: "pe Elims = -- | elim"
10+ after: "pe Elims =\n -- | el"
11+Please, consider reporting the bug.
12+
13+Parsing of formatted code failed:
14+ src/full/Agda/Syntax/Translation/ConcreteToAbstract.hs<rendered>:509:7-13
15+ parse error on input `C.QName'
16+Please, consider reporting the bug.
17+
18+Formatting is not idempotent:
19+ src/full/Agda/Termination/CallGraph.hs<rendered>:152:38
20+ before: "2, old2) = -- TODO: "
21+ after: "2, old2) =\n -"
22+Please, consider reporting the bug.
23+
24+Formatting is not idempotent:
25+ src/full/Agda/TypeChecking/MetaVars.hs<rendered>:1419:16
26+ before: "ubstCand = -- | a po"
27+ after: "ubstCand =\n -- | a "
28+Please, consider reporting the bug.
29+
30+Formatting is not idempotent:
31+ src/full/Agda/Utils/List.hs<rendered>:186:15
32+ before: "Prefix a = -- | The "
33+ after: "Prefix a =\n -- | Th"
34+Please, consider reporting the bug.
35+
expected-failures/aws.txtnew file+10
@@ -0,0 +1,10 @@
1+Parsing of source code failed:
2+ Examples/PutBucketNearLine.hs:5:1-6
3+ parse error on input `import'
4+
5+Parsing of source code failed:
6+ Examples/Sqs.hs:(88,3)-(90,4)
7+ parse error on input `{- | Let's make sure the queue was actually deleted and that the same number of queues exist at when
8+ | the program ends as when it started.
9+ -}'
10+
expected-failures/brick.txtnew file+6
@@ -0,0 +1,6 @@
1+Formatting is not idempotent:
2+ src/Brick/Widgets/List.hs<rendered>:571:3
3+ before: "t at i\n in -- If t"
4+ after: "t at i\n -"
5+Please, consider reporting the bug.
6+
expected-failures/distributed-process.txtnew file+8
@@ -0,0 +1,8 @@
1+Parsing of source code failed:
2+ benchmarks/Channels.hs:2:1-6
3+ parse error on input `import'
4+
5+Parsing of source code failed:
6+ benchmarks/Spawns.hs:5:1-6
7+ parse error on input `import'
8+
expected-failures/esqueleto.txtnew file+8
@@ -0,0 +1,8 @@
1+Parsing of source code failed:
2+ src/Database/Esqueleto/Internal/Internal.hs:379:1
3+ lexical error in string/character literal at character 's'
4+
5+Parsing of source code failed:
6+ test/PostgreSQL/Test.hs:510:9-41
7+ parse error on input `-- | Check the result is not null'
8+
expected-failures/fay.txtnew file+19
@@ -0,0 +1,19 @@
1+Parsing of source code failed:
2+ examples/Separated.hs:12:1-6
3+ parse error on input `module'
4+
5+Parsing of source code failed:
6+ examples/calc.hs:(4,1)-(6,2)
7+ parse error on input `-- $ fay -p --html-wrapper --html-js-lib jquery.min.js examples/calc.hs
8+-- You also need to download jquery.min.js.
9+--'
10+
11+Parsing of source code failed:
12+ examples/canvaswater.hs:(6,1)-(7,17)
13+ parse error on input `-- | A demonstration of Fay using the canvas element to display a
14+-- simple effect.'
15+
16+Parsing of source code failed:
17+ examples/data.hs:9:1-6
18+ parse error on input `module'
19+
expected-failures/idris.txtnew file+102
@@ -0,0 +1,102 @@
1+Formatting is not idempotent:
2+ src/Idris/AbsSyntaxTree.hs<rendered>:2105:48
3+ before: "t_impl ppo && uname "
4+ after: "t_impl ppo\n "
5+Please, consider reporting the bug.
6+
7+Formatting is not idempotent:
8+ src/Idris/Core/ProofState.hs<rendered>:163:20
9+ before: "++ showEnv env (\n "
10+ after: "++ showEnv\n "
11+Please, consider reporting the bug.
12+
13+Formatting is not idempotent:
14+ src/Idris/Core/ProofTerm.hs<rendered>:351:19
15+ before: "f c e pt = -- @(PT p"
16+ after: "f c e pt =\n -- @(PT"
17+Please, consider reporting the bug.
18+
19+Formatting is not idempotent:
20+ src/Idris/Core/TT.hs<rendered>:1963:13
21+ before: " text op <> pretty"
22+ after: " text op\n <"
23+Please, consider reporting the bug.
24+
25+Formatting is not idempotent:
26+ src/Idris/Core/WHNF.hs<rendered>:110:46
27+ before: " n b sc) = -- stk mu"
28+ after: " n b sc) =\n -- "
29+Please, consider reporting the bug.
30+
31+Formatting is not idempotent:
32+ src/Idris/Delaborate.hs<rendered>:627:6
33+ before: "ity\n -- Issue #"
34+ after: "ity\n -- Issue"
35+Please, consider reporting the bug.
36+
37+Formatting is not idempotent:
38+ src/Idris/Elab/Term.hs<rendered>:423:47
39+ before: "K\" _ _)) = -- for ch"
40+ after: "K\" _ _)) =\n -- "
41+Please, consider reporting the bug.
42+
43+Formatting is not idempotent:
44+ src/Idris/ModeCommon.hs<rendered>:40:26
45+ before: "s toline = -- furthe"
46+ after: "s toline =\n -- furt"
47+Please, consider reporting the bug.
48+
49+Formatting is not idempotent:
50+ src/Idris/Options.hs<rendered>:177:17
51+ before: "timisation = PETrans"
52+ after: "timisation\n = PETra"
53+Please, consider reporting the bug.
54+
55+Parsing of source code failed:
56+ src/Idris/Parser.hs:1052:1
57+ parse error on input `@'
58+
59+AST of input and AST of formatted code differ.
60+ at src/Idris/Parser/Data.hs:281:1-29
61+Please, consider reporting the bug.
62+
63+Parsing of source code failed:
64+ src/Idris/Parser/Expr.hs:75:1
65+ parse error on input `@'
66+
67+Formatting is not idempotent:
68+ src/Idris/PartialEval.hs<rendered>:280:42
69+ before: ": ns) as = -- Droppe"
70+ after: ": ns) as =\n -- "
71+Please, consider reporting the bug.
72+
73+Formatting is not idempotent:
74+ src/Idris/ProofSearch.hs<rendered>:483:20
75+ before: "OK ty hs = -- if any"
76+ after: "OK ty hs =\n -- "
77+Please, consider reporting the bug.
78+
79+Formatting is not idempotent:
80+ src/Idris/Prover.hs<rendered>:244:10
81+ before: " line <> bindin"
82+ after: " line\n <"
83+Please, consider reporting the bug.
84+
85+Formatting is not idempotent:
86+ src/Idris/REPL.hs<rendered>:1271:33
87+ before: "ht c) _) = -- consta"
88+ after: "ht c) _) =\n -- cons"
89+Please, consider reporting the bug.
90+
91+Formatting is not idempotent:
92+ src/Idris/Reflection.hs<rendered>:934:27
93+ before: "attern _ = -- for al"
94+ after: "attern _ =\n -- for "
95+Please, consider reporting the bug.
96+
97+Formatting is not idempotent:
98+ src/Idris/Transforms.hs<rendered>:26:32
99+ before: "s, rhs)) = -- apply "
100+ after: "s, rhs)) =\n -- "
101+Please, consider reporting the bug.
102+
expected-failures/intero.txtnew file+6
@@ -0,0 +1,6 @@
1+Formatting is not idempotent:
2+ src/InteractiveUI.hs<rendered>:2595:36
3+ before: "Decl d2) = -- A bit "
4+ after: "Decl d2) =\n -- A bi"
5+Please, consider reporting the bug.
6+
expected-failures/leksah.txtnew file+12
@@ -0,0 +1,12 @@
1+Formatting is not idempotent:
2+ src/IDE/Pane/Modules.hs<rendered>:1182:7
3+ before: "cr\n -- show"
4+ after: "cr\n in -- show"
5+Please, consider reporting the bug.
6+
7+Formatting is not idempotent:
8+ src/IDE/SymbolNavigation.hs<rendered>:229:8
9+ before: ")\n return [\n {-i"
10+ after: ")\n return\n [ {-i"
11+Please, consider reporting the bug.
12+
expected-failures/lens.txtnew file+4
@@ -0,0 +1,4 @@
1+Parsing of source code failed:
2+ src/Control/Exception/Lens.hs:180:13-37
3+ parse error on input `AllocationLimitExceeded__'
4+
expected-failures/pandoc.txtnew file+16
@@ -0,0 +1,16 @@
1+Parsing of source code failed:
2+ benchmark/weigh-pandoc.hs:14:1-6
3+ parse error on input `import'
4+
5+Formatting is not idempotent:
6+ src/Text/Pandoc/Readers/Vimwiki.hs<rendered>:615:19
7+ before: ".softbreak <$ endlin"
8+ after: ".softbreak\n <$ en"
9+Please, consider reporting the bug.
10+
11+Formatting is not idempotent:
12+ src/Text/Pandoc/Writers/Docx.hs<rendered>:960:25
13+ before: " -- w:p\n "
14+ after: " -- w:p\n "
15+Please, consider reporting the bug.
16+
expected-failures/pipes.txtnew file+4
@@ -0,0 +1,4 @@
1+AST of input and AST of formatted code differ.
2+ at src/Pipes/Core.hs:(128,1)-(151,2)
3+Please, consider reporting the bug.
4+
expected-failures/purescript.txtnew file+19
@@ -0,0 +1,19 @@
1+Parsing of source code failed:
2+ src/Language/PureScript/AST/Declarations.hs:478:1-17
3+ Invalid type signature: pattern ValueDecl :: ...
4+Perhaps you meant to use PatternSynonyms?
5+
6+Parsing of source code failed:
7+ src/Language/PureScript/AST/SourcePos.hs:101:1-22
8+ Invalid type signature: pattern NullSourceSpan :: ...
9+Perhaps you meant to use PatternSynonyms?
10+
11+Parsing of source code failed:
12+ src/Language/PureScript/Constants.hs:42:1-15
13+ Invalid type signature: pattern Discard :: ...
14+Perhaps you meant to use PatternSynonyms?
15+
16+Parsing of source code failed:
17+ src/Language/PureScript/Crash.hs:16:1-6
18+ parse error on input `import'
19+
expected-failures/stack.txtnew file+6
@@ -0,0 +1,6 @@
1+Formatting is not idempotent:
2+ src/Stack/Options/DockerParser.hs<rendered>:36:10
3+ before: " <$> opti"
4+ after: " <$> option"
5+Please, consider reporting the bug.
6+
nix/ormolize/default.nix+28−10
@@ -2,8 +2,8 @@
22, haskellPackages
33}:
44{ package
5+, expectedFailures ? null
56, doCheck ? false
6−, excludedDirs ? []
77}:
88 pkgs.stdenv.mkDerivation rec {
99 name = package.name + "-ormolized";
@@ -14,20 +14,38 @@
1414 then haskellPackages.ormolu
1515 else pkgs.haskell.lib.dontCheck haskellPackages.ormolu)
1616 pkgs.glibcLocales
17+ pkgs.diffutils
1718 ];
1819 LANG = "en_US.UTF-8";
19− excludedDirsRendered =
20− if excludedDirs == []
21− then ""
22− else pkgs.lib.concatMapStringsSep " " (x: "-not -path './" + x + "/*'") excludedDirs;
2320 buildPhase = ''
24− find . -name '*.hs' ${excludedDirsRendered} -exec bash ${./ormolize.sh} {} \; 2> log.txt
25− cat log.txt
21+ hs_files=$(find . -name '*.hs')
22+ for hs_file in $hs_files; do
23+
24+ # drop includes
25+ sed -i '/^#include/d' "$hs_file"
26+
27+ # deal with CPP
28+ cpphs "$hs_file" --noline -DARCH_X86 > "''${hs_file}-nocpp" 2> /dev/null
29+
30+ # annoyingly, cpphs cannot modify files in place
31+ mv "''${hs_file}-nocpp" "$hs_file"
32+
33+ # preserve the original
34+ cp "$hs_file" "''${hs_file}-original"
35+ done
36+
37+ (ormolu --tolerate-cpp --check-idempotency --mode inplace $hs_files || true) 2> log.txt
2638 '';
2739 inherit doCheck;
28− checkPhase = ''
29− if [[ -s log.txt ]]; then exit 1; fi
30− '';
40+ checkPhase =
41+ if expectedFailures == null
42+ then ''
43+ echo "No failures expected"
44+ if [[ -s log.txt ]]; then exit 1; fi
45+ ''
46+ else ''
47+ diff --color=always ${expectedFailures} log.txt
48+ '';
3149 installPhase = ''
3250 mkdir "$out"
3351 find . -name '*.hs-original' -exec cp --parents {} $out \;
nix/ormolize/ormolize.shdeleted−17
@@ -1,17 +0,0 @@
1−set -euo pipefail
2−
3−# drop includes
4−sed -i '/^#include/d' "$1"
5−
6−# deal with CPP in a fairly straightforward way
7−cpphs "$1" --noline > "$1-nocpp" 2> /dev/null
8−
9−# annoyingly, cpphs cannot modify files in place
10−mv "$1-nocpp" "$1"
11−
12−# preserve the original
13−cp "$1" "$1-original"
14−
15−# run ormolu
16−ormolu --tolerate-cpp --check-idempotency --mode inplace "$1" ||
17− ormolu --tolerate-cpp --unsafe --mode inplace "$1"