@@ -23,130 +23,129 @@ import IntegrationTesting
23
23
24
24
main :: IO ()
25
25
main = hspec $ do
26
- afterAll_ shutdownBazel $
27
- describe " root workspace" $ do
28
- it " bazel test" $ do
29
- assertSuccess (bazel [" test" , " //..." ])
30
-
31
- it " bazel test prof" $ do
32
- ghcVersion <- lookupEnv " GHC_VERSION"
33
-
34
- -- In .github/workflows/workflow.yaml we specify --test_tag_filters
35
- -- -dont_test_on_darwin. However, specifiying --test_tag_filters
36
- -- -requires_dynamic here alone would override that filter. So,
37
- -- we have to duplicate that filter here.
38
- let tagFilter | os == " darwin" = " -dont_test_on_darwin,-requires_dynamic,-skip_profiling" ++ (
39
- -- skip tests for specific GHC version, see https://github.com/tweag/rules_haskell/issues/2073
40
- maybe " " (" ,-dont_build_on_macos_with_ghc_" ++ ) ghcVersion)
41
- | otherwise = " -requires_dynamic,-skip_profiling"
42
- assertSuccess (bazel [" test" , " -c" , " dbg" , " //..." , " --build_tag_filters" , tagFilter, " --test_tag_filters" , tagFilter])
43
-
44
- it " bazel build worker" $ do
45
- assertSuccess (bazel [" build" , " @rules_haskell//tools/worker:bin" ])
46
-
47
- describe " stack_snapshot pinning" $
48
- it " handles packages in subdirectories correctly" $ do
49
- -- NOTE Keep in sync with
50
- -- .github/workflows/workflow.yaml
51
- let withBackup filename k =
52
- withSystemTempDirectory " bazel_backup" $ \ tmp_dir -> do
53
- bracket_
54
- (copyFile filename (tmp_dir </> " backup" ))
55
- (copyFile (tmp_dir </> " backup" ) filename)
56
- k
57
- -- Test that pinning works and produces buildable targets.
58
- -- Backup the lock file to avoid unintended changes when run locally.
59
- withBackup " stackage-pinning-test_snapshot.json" $ do
60
- assertSuccess (bazel [" run" , " @stackage-pinning-test-unpinned//:pin" ])
61
- assertSuccess (bazel [" build" , " @stackage-pinning-test//:hspec" ])
62
-
63
- describe " repl" $ do
64
- it " for libraries" $ do
65
- assertSuccess (bazel [" run" , " //tests/repl-targets:hs-lib-bad@repl" , " --" , " -ignore-dot-ghci" , " -e" , " 1 + 2" ])
66
-
67
- it " for binaries" $ do
68
- assertSuccess (bazel [" run" , " //tests/binary-indirect-cbits:binary-indirect-cbits@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
69
-
70
- assertSuccess (bazel [" run" , " //tests/repl-targets:hs-test-bad@repl" , " --" , " -ignore-dot-ghci" , " -e" , " 1 + 2" ])
71
-
72
- it " with rebindable syntax" $ do
73
- let p' (stdout, _stderr) = lines stdout == [" True" ]
74
- outputSatisfy p' (bazel [" run" , " //tests/repl-targets:rebindable-syntax@repl" , " --" , " -ignore-dot-ghci" , " -e" , " check" ])
75
-
76
- it " sets classpath" $ do
77
- assertSuccess (bazel [" run" , " //tests/java_classpath:java_classpath@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
78
-
79
- -- Test `compiler_flags` from toolchain and rule for REPL
26
+ afterAll_ shutdownBazel $ do
27
+ it " bazel test" $ do
28
+ assertSuccess (bazel [" test" , " //..." ])
29
+
30
+ it " bazel test prof" $ do
31
+ ghcVersion <- lookupEnv " GHC_VERSION"
32
+
33
+ -- In .github/workflows/workflow.yaml we specify --test_tag_filters
34
+ -- -dont_test_on_darwin. However, specifiying --test_tag_filters
35
+ -- -requires_dynamic here alone would override that filter. So,
36
+ -- we have to duplicate that filter here.
37
+ let tagFilter | os == " darwin" = " -dont_test_on_darwin,-requires_dynamic,-skip_profiling" ++ (
38
+ -- skip tests for specific GHC version, see https://github.com/tweag/rules_haskell/issues/2073
39
+ maybe " " (" ,-dont_build_on_macos_with_ghc_" ++ ) ghcVersion)
40
+ | otherwise = " -requires_dynamic,-skip_profiling"
41
+ assertSuccess (bazel [" test" , " -c" , " dbg" , " //..." , " --build_tag_filters" , tagFilter, " --test_tag_filters" , tagFilter])
42
+
43
+ it " bazel build worker" $ do
44
+ assertSuccess (bazel [" build" , " @rules_haskell//tools/worker:bin" ])
45
+
46
+ describe " stack_snapshot pinning" $
47
+ it " handles packages in subdirectories correctly" $ do
48
+ -- NOTE Keep in sync with
49
+ -- .github/workflows/workflow.yaml
50
+ let withBackup filename k =
51
+ withSystemTempDirectory " bazel_backup" $ \ tmp_dir -> do
52
+ bracket_
53
+ (copyFile filename (tmp_dir </> " backup" ))
54
+ (copyFile (tmp_dir </> " backup" ) filename)
55
+ k
56
+ -- Test that pinning works and produces buildable targets.
57
+ -- Backup the lock file to avoid unintended changes when run locally.
58
+ withBackup " stackage-pinning-test_snapshot.json" $ do
59
+ assertSuccess (bazel [" run" , " @stackage-pinning-test-unpinned//:pin" ])
60
+ assertSuccess (bazel [" build" , " @stackage-pinning-test//:hspec" ])
61
+
62
+ describe " repl" $ do
63
+ it " for libraries" $ do
64
+ assertSuccess (bazel [" run" , " //tests/repl-targets:hs-lib-bad@repl" , " --" , " -ignore-dot-ghci" , " -e" , " 1 + 2" ])
65
+
66
+ it " for binaries" $ do
67
+ assertSuccess (bazel [" run" , " //tests/binary-indirect-cbits:binary-indirect-cbits@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
68
+
69
+ assertSuccess (bazel [" run" , " //tests/repl-targets:hs-test-bad@repl" , " --" , " -ignore-dot-ghci" , " -e" , " 1 + 2" ])
70
+
71
+ it " with rebindable syntax" $ do
72
+ let p' (stdout, _stderr) = lines stdout == [" True" ]
73
+ outputSatisfy p' (bazel [" run" , " //tests/repl-targets:rebindable-syntax@repl" , " --" , " -ignore-dot-ghci" , " -e" , " check" ])
74
+
75
+ it " sets classpath" $ do
76
+ assertSuccess (bazel [" run" , " //tests/java_classpath:java_classpath@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
77
+
78
+ -- Test `compiler_flags` from toolchain and rule for REPL
79
+ it " compiler flags" $ do
80
+ assertSuccess (bazel [" run" , " //tests/repl-flags:compiler_flags@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
81
+
82
+ -- Test make variable expansion in `compiler_flags` and `repl_ghci_args`.
83
+ describe " make variables" $ do
80
84
it " compiler flags" $ do
81
- assertSuccess (bazel [" run" , " //tests/repl-flags:compiler_flags@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
82
-
83
- -- Test make variable expansion in `compiler_flags` and `repl_ghci_args`.
84
- describe " make variables" $ do
85
- it " compiler flags" $ do
86
- assertSuccess (bazel [" run" , " //tests/repl-make-variables:test-compiler-flags@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
87
- it " indirect repl flags" $ do
88
- assertSuccess (bazel [" run" , " //tests/repl-make-variables:repl-indirect-flags" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
89
- it " direct repl flags" $ do
90
- assertSuccess (bazel [" run" , " //tests/repl-make-variables:repl-direct-flags" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
91
-
92
- -- Test `repl_ghci_args` from toolchain and rule for REPL
93
- it " repl flags" $ do
94
- assertSuccess (bazel [" run" , " //tests/repl-flags:repl_flags@repl" , " --" , " -ignore-dot-ghci" , " -e" , " foo" ])
95
-
96
- it " fails on multiple definitions" $ do
97
- assertSuccess (bazel [" run" , " //tests/repl-multiple-definition:repl" , " --" , " -ignore-dot-ghci" , " -e" , " final" ])
98
-
99
- describe " multi_repl" $ do
100
- it " loads transitive library dependencies" $ do
101
- let p' (stdout, _stderr) = lines stdout == [" tests/multi_repl/bc/src/BC/C.hs" ]
102
- outputSatisfy p' (bazel [" run" , " //tests/multi_repl:c_only_repl" , " --" , " -ignore-dot-ghci" , " -e" , " :show targets" ])
103
- it " loads transitive source dependencies" $ do
104
- let p' (stdout, _stderr) = sort (lines stdout) == [" tests/multi_repl/a/src/A/A.hs" ," tests/multi_repl/bc/src/BC/B.hs" ," tests/multi_repl/bc/src/BC/C.hs" ]
105
- outputSatisfy p' (bazel [" run" , " //tests/multi_repl:c_multi_repl" , " --" , " -ignore-dot-ghci" , " -e" , " :show targets" ])
106
- it " loads core library dependencies" $ do
107
- let p' (stdout, _stderr) = sort (lines stdout) == [" tests/multi_repl/core_package_dep/Lib.hs" ]
108
- outputSatisfy p' (bazel [" run" , " //tests/multi_repl:core_package_dep" , " --" , " -ignore-dot-ghci" , " -e" , " :show targets" ])
109
- it " doesn't allow to manually load modules" $ do
110
- assertFailure (bazel [" run" , " //tests/multi_repl:c_multi_repl" , " --" , " -ignore-dot-ghci" , " -e" , " :load BC.C" , " -e" , " c" ])
111
-
112
- describe " ghcide" $ do
113
- it " loads RunTests.hs" $
114
- assertSuccess (Process. proc " ./.ghcide" [" tests/RunTests.hs" ])
115
- it " loads module with module dependency" $
116
- assertSuccess (Process. proc " ./.ghcide" [" tests/binary-with-lib/Main.hs" ])
117
-
118
- describe " failures" $ do
119
- -- Make sure not to include haskell_repl (@repl) or alias (-repl) targets
120
- -- in the query. Those would not fail under bazel test.
121
- all_failure_tests <- bazelQuery " kind('haskell_library|haskell_binary|haskell_test', //tests/failures/...) intersect attr('tags', 'manual', //tests/failures/...)"
122
-
123
- for_ all_failure_tests $ \ test -> do
124
- it test $ do
125
- assertFailure (bazel [" build" , test])
126
-
127
- context " known issues" $ do
128
- it " haskell_doc fails with plugins #1549" $
129
- -- https://github.com/tweag/rules_haskell/issues/1549
130
- assertFailure (bazel [" build" , " //tests/haddock-with-plugin" ])
131
- it " transitive re-exports do not work #1145" $
132
- -- https://github.com/tweag/rules_haskell/issues/1145
133
- assertFailure (bazel [" build" , " //tests/package-reexport-transitive" ])
134
- it " doctest failure with foreign import #1559" $
135
- -- https://github.com/tweag/rules_haskell/issues/1559
136
- assertFailure (bazel [" build" , " //tests/haskell_doctest_ffi_1559:doctest-a" ])
137
-
138
- -- Test that the repl still works if we shadow some Prelude functions
139
- it " repl name shadowing" $ do
140
- let p (stdout, stderr) = not $ any (" error" `isInfixOf` ) [stdout, stderr]
141
- outputSatisfy p (bazel [" run" , " //tests/repl-name-conflicts:lib@repl" , " --" , " -ignore-dot-ghci" , " -e" , " stdin" ])
142
-
143
- it " Repl works with remote_download_toplevel" $ do
144
- let p (stdout, stderr) = not $ any (" error" `isInfixOf` ) [stdout, stderr]
145
- withSystemTempDirectory " bazel_disk_cache" $ \ tmp_disk_cache -> do
146
- assertSuccess $ bazel [" run" , " //tests/multi_repl:c_only_repl" , " --disk_cache=" <> tmp_disk_cache]
147
- assertSuccess $ bazel [" clean" ]
148
- outputSatisfy p
149
- (bazel [" run" , " //tests/multi_repl:c_only_repl" , " --disk_cache=" <> tmp_disk_cache, " --remote_download_toplevel" ])
85
+ assertSuccess (bazel [" run" , " //tests/repl-make-variables:test-compiler-flags@repl" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
86
+ it " indirect repl flags" $ do
87
+ assertSuccess (bazel [" run" , " //tests/repl-make-variables:repl-indirect-flags" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
88
+ it " direct repl flags" $ do
89
+ assertSuccess (bazel [" run" , " //tests/repl-make-variables:repl-direct-flags" , " --" , " -ignore-dot-ghci" , " -e" , " :main" ])
90
+
91
+ -- Test `repl_ghci_args` from toolchain and rule for REPL
92
+ it " repl flags" $ do
93
+ assertSuccess (bazel [" run" , " //tests/repl-flags:repl_flags@repl" , " --" , " -ignore-dot-ghci" , " -e" , " foo" ])
94
+
95
+ it " fails on multiple definitions" $ do
96
+ assertSuccess (bazel [" run" , " //tests/repl-multiple-definition:repl" , " --" , " -ignore-dot-ghci" , " -e" , " final" ])
97
+
98
+ describe " multi_repl" $ do
99
+ it " loads transitive library dependencies" $ do
100
+ let p' (stdout, _stderr) = lines stdout == [" tests/multi_repl/bc/src/BC/C.hs" ]
101
+ outputSatisfy p' (bazel [" run" , " //tests/multi_repl:c_only_repl" , " --" , " -ignore-dot-ghci" , " -e" , " :show targets" ])
102
+ it " loads transitive source dependencies" $ do
103
+ let p' (stdout, _stderr) = sort (lines stdout) == [" tests/multi_repl/a/src/A/A.hs" ," tests/multi_repl/bc/src/BC/B.hs" ," tests/multi_repl/bc/src/BC/C.hs" ]
104
+ outputSatisfy p' (bazel [" run" , " //tests/multi_repl:c_multi_repl" , " --" , " -ignore-dot-ghci" , " -e" , " :show targets" ])
105
+ it " loads core library dependencies" $ do
106
+ let p' (stdout, _stderr) = sort (lines stdout) == [" tests/multi_repl/core_package_dep/Lib.hs" ]
107
+ outputSatisfy p' (bazel [" run" , " //tests/multi_repl:core_package_dep" , " --" , " -ignore-dot-ghci" , " -e" , " :show targets" ])
108
+ it " doesn't allow to manually load modules" $ do
109
+ assertFailure (bazel [" run" , " //tests/multi_repl:c_multi_repl" , " --" , " -ignore-dot-ghci" , " -e" , " :load BC.C" , " -e" , " c" ])
110
+
111
+ describe " ghcide" $ do
112
+ it " loads RunTests.hs" $
113
+ assertSuccess (Process. proc " ./.ghcide" [" tests/RunTests.hs" ])
114
+ it " loads module with module dependency" $
115
+ assertSuccess (Process. proc " ./.ghcide" [" tests/binary-with-lib/Main.hs" ])
116
+
117
+ describe " failures" $ do
118
+ -- Make sure not to include haskell_repl (@repl) or alias (-repl) targets
119
+ -- in the query. Those would not fail under bazel test.
120
+ all_failure_tests <- bazelQuery " kind('haskell_library|haskell_binary|haskell_test', //tests/failures/...) intersect attr('tags', 'manual', //tests/failures/...)"
121
+
122
+ for_ all_failure_tests $ \ test -> do
123
+ it test $ do
124
+ assertFailure (bazel [" build" , test])
125
+
126
+ context " known issues" $ do
127
+ it " haskell_doc fails with plugins #1549" $
128
+ -- https://github.com/tweag/rules_haskell/issues/1549
129
+ assertFailure (bazel [" build" , " //tests/haddock-with-plugin" ])
130
+ it " transitive re-exports do not work #1145" $
131
+ -- https://github.com/tweag/rules_haskell/issues/1145
132
+ assertFailure (bazel [" build" , " //tests/package-reexport-transitive" ])
133
+ it " doctest failure with foreign import #1559" $
134
+ -- https://github.com/tweag/rules_haskell/issues/1559
135
+ assertFailure (bazel [" build" , " //tests/haskell_doctest_ffi_1559:doctest-a" ])
136
+
137
+ -- Test that the repl still works if we shadow some Prelude functions
138
+ it " repl name shadowing" $ do
139
+ let p (stdout, stderr) = not $ any (" error" `isInfixOf` ) [stdout, stderr]
140
+ outputSatisfy p (bazel [" run" , " //tests/repl-name-conflicts:lib@repl" , " --" , " -ignore-dot-ghci" , " -e" , " stdin" ])
141
+
142
+ it " Repl works with remote_download_toplevel" $ do
143
+ let p (stdout, stderr) = not $ any (" error" `isInfixOf` ) [stdout, stderr]
144
+ withSystemTempDirectory " bazel_disk_cache" $ \ tmp_disk_cache -> do
145
+ assertSuccess $ bazel [" run" , " //tests/multi_repl:c_only_repl" , " --disk_cache=" <> tmp_disk_cache]
146
+ assertSuccess $ bazel [" clean" ]
147
+ outputSatisfy p
148
+ (bazel [" run" , " //tests/multi_repl:c_only_repl" , " --disk_cache=" <> tmp_disk_cache, " --remote_download_toplevel" ])
150
149
151
150
it " bazel test examples" $ do
152
151
assertSuccess $ (bazel [" build" , " //..." ]) { Process. cwd = Just " ../examples" }
@@ -171,6 +170,7 @@ bazelQuery q = lines <$> runIO (Process.readProcess "bazel" ["query", q] "")
171
170
172
171
shutdownBazel :: IO ()
173
172
shutdownBazel = do
173
+ putStrLn " MADE IT!"
174
174
assertSuccess (bazel [" shutdown" ])
175
175
pure ()
176
176
0 commit comments