Skip to content

Commit 7af335c

Browse files
committed
Add tests for .local and .freeze monitoring
1 parent cd4579d commit 7af335c

8 files changed

Lines changed: 107 additions & 16 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- cabal-project-repro-0.1.0.0 (test:cabal-project-repro-test) (first run)
6+
- cabal-project-repro-0.1.0.0 (exe:filemonitor-test) (first run)
7+
Configuring test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
8+
Warning: [unknown-file] The 'license-file' field refers to the file 'LICENSE' which does not exist.
9+
Preprocessing test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
10+
Building test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
11+
Error: [Cabal-7125]
12+
Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test.
13+
# cabal build
14+
Resolving dependencies...
15+
Build profile: -w ghc-<GHCVER> -O1
16+
In order, the following will be built:
17+
- cabal-project-repro-0.1.0.0 (exe:filemonitor-test) (first run)
18+
Configuring executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
19+
Warning: [unknown-file] The 'license-file' field refers to the file 'LICENSE' which does not exist.
20+
Preprocessing executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
21+
Building executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
22+
# cabal build
23+
Resolving dependencies...
24+
Build profile: -w ghc-<GHCVER> -O1
25+
In order, the following will be built:
26+
- cabal-project-repro-0.1.0.0 (test:cabal-project-repro-test) (first run)
27+
- cabal-project-repro-0.1.0.0 (exe:filemonitor-test) (configuration changed)
28+
Preprocessing test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
29+
Building test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
30+
Error: [Cabal-7125]
31+
Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- NOTE: Intentionally empty as we can't specify
2+
-- --project-file=cabal.freeze-only.project when that file doesn't exist.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
packages: ./cabal-project-repro.cabal
2+
3+
package *
4+
Tests: True
5+
6+
import: nested/hop.config
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- cabal-project-repro-0.1.0.0 (test:cabal-project-repro-test) (first run)
6+
- cabal-project-repro-0.1.0.0 (exe:filemonitor-test) (first run)
7+
Configuring test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
8+
Warning: [unknown-file] The 'license-file' field refers to the file 'LICENSE' which does not exist.
9+
Preprocessing test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
10+
Building test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
11+
Error: [Cabal-7125]
12+
Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test.
13+
# cabal build
14+
Resolving dependencies...
15+
Build profile: -w ghc-<GHCVER> -O1
16+
In order, the following will be built:
17+
- cabal-project-repro-0.1.0.0 (exe:filemonitor-test) (first run)
18+
Configuring executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
19+
Warning: [unknown-file] The 'license-file' field refers to the file 'LICENSE' which does not exist.
20+
Preprocessing executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
21+
Building executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
22+
# cabal build
23+
Resolving dependencies...
24+
Build profile: -w ghc-<GHCVER> -O1
25+
In order, the following will be built:
26+
- cabal-project-repro-0.1.0.0 (test:cabal-project-repro-test) (first run)
27+
- cabal-project-repro-0.1.0.0 (exe:filemonitor-test) (configuration changed)
28+
Preprocessing test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
29+
Building test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
30+
Error: [Cabal-7125]
31+
Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- NOTE: Intentionally empty as we can't specify
2+
-- --project-file=cabal.local-only.project when that file doesn't exist.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
packages: ./cabal-project-repro.cabal
2+
3+
package *
4+
Tests: True
5+
6+
import: nested/hop.config

cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Warning: [unknown-file] The 'license-file' field refers to the file 'LICENSE' wh
2020
Preprocessing executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
2121
Building executable 'filemonitor-test' for cabal-project-repro-0.1.0.0...
2222
# cabal build
23-
Up to date
24-
# cabal build
2523
Resolving dependencies...
2624
Build profile: -w ghc-<GHCVER> -O1
2725
In order, the following will be built:
@@ -31,3 +29,6 @@ Preprocessing test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.
3129
Building test suite 'cabal-project-repro-test' for cabal-project-repro-0.1.0.0...
3230
Error: [Cabal-7125]
3331
Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test.
32+
# cabal build
33+
Resolving dependencies...
34+
Up to date

cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.test.hs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,32 @@ import System.IO
1010
-- |
1111
-- 4 | main = puStrLn "Test suite not yet implemented."
1212
-- |
13-
main = cabalTest' "main-project" . recordMode RecordMarked $ do
14-
projEnabledTests <- fails $ cabal' "build" []
15-
assertExitCode (ExitFailure 1) projEnabledTests
16-
assertOutputContains "Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test." projEnabledTests
13+
main = do
14+
cabalTest' "main-project" . recordMode RecordMarked $
15+
runTest ["--project-file=cabal.project"] True
16+
cabalTest' "local-only" . recordMode RecordMarked $
17+
runTest ["--project-file=cabal.local-only.project"] False
18+
cabalTest' "freeze-only" . recordMode RecordMarked $
19+
runTest ["--project-file=cabal.freeze-only.project"] False
20+
where
21+
testNotYetImplemented = "Test suite not yet implemented"
1722

18-
cmdDisabledTests <- cabal' "build" ["--disable-tests"]
19-
assertOutputDoesNotContain "Test suite not yet implement" cmdDisabledTests
23+
runTest projOpts toggle = do
24+
projEnabledTests <- fails $ cabal' "build" projOpts
25+
assertExitCode (ExitFailure 1) projEnabledTests
26+
assertOutputContains "Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test." projEnabledTests
2027

21-
-- Change the imported project file with "Tests: False"
22-
test_dir <- fmap testTmpDir getTestEnv
23-
liftIO $ writeFile (test_dir </> "test" </> "tests-toggle.config") "package *\n Tests: False"
24-
projDisabledTests <- cabal' "build" []
25-
assertOutputDoesNotContain "Test suite not yet implement" projDisabledTests
26-
assertOutputDoesNotContain "Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test." projDisabledTests
28+
cmdDisabledTests <- cabal' "build" (projOpts ++ ["--disable-tests"])
29+
assertOutputDoesNotContain testNotYetImplemented cmdDisabledTests
2730

28-
cmdEnabledTests <- fails $ cabal' "build" ["--enable-tests"]
29-
assertOutputContains "Test suite not yet implement" cmdEnabledTests
31+
cmdEnabledTests <- fails $ cabal' "build" (projOpts ++ ["--enable-tests"])
32+
assertOutputContains testNotYetImplemented cmdEnabledTests
33+
34+
when toggle $ do
35+
-- Change the imported project file with "Tests: False"
36+
test_dir <- fmap testTmpDir getTestEnv
37+
liftIO $ writeFile (test_dir </> "test" </> "tests-toggle.config") "package *\n Tests: False"
38+
projDisabledTests <- cabal' "build" projOpts
39+
assertOutputDoesNotContain "Test suite not yet implement" projDisabledTests
40+
assertOutputDoesNotContain "Failed to build cabal-project-repro-0.1.0.0-inplace-cabal-project-repro-test." projDisabledTests
41+
liftIO $ writeFile (test_dir </> "test" </> "tests-toggle.config") "package *\n Tests: True"

0 commit comments

Comments
 (0)