Skip to content
Snippets Groups Projects
Unverified Commit 663e98f8 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub
Browse files

Merge pull request #9680 from cabalism/test/project-hop-imports

Add tests for project imports and constraint version conflicts
parents bd0dae73 78fcdc68
No related branches found
No related tags found
No related merge requests found
Showing
with 130 additions and 2 deletions
packages: .
import: cabal-cyclical-1-hop.config
import: cabal-cyclical-2-hop-2.config
import: cabal-cyclical-2-hop.project
packages: .
import: cabal-cyclical-2-hop-1.config
import: cabal-cyclical-1-hop.project
......@@ -40,6 +40,34 @@ cyclical import of cyclical-2-out-out-back-a.config
Error: [Cabal-7090]
Error parsing project file <ROOT>/cyclical-2-out-out-self.project:1:
cyclical import of cyclical-2-out-out-self-b.config
# checking that cyclical check doesn't false-positive on same file names in different folders; hoping within a folder and then into a subfolder
# cabal v2-build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- my-0.1 (lib:my) (first run)
Configuring my-0.1...
Preprocessing library for my-0.1...
Building library for my-0.1...
# checking that cyclical check doesn't false-positive on same file names in different folders; hoping into a subfolder and then back out again
# cabal v2-build
# checking that cyclical check catches a same file name that imports itself
# cabal v2-build
Error: [Cabal-7090]
Error parsing project file <ROOT>/cyclical-same-filename-out-out-self.project:1:
cyclical import of cyclical-same-filename-out-out-self.config
# checking that cyclical check catches importing its importer (with the same file name)
# cabal v2-build
Error: [Cabal-7090]
Error parsing project file <ROOT>/cyclical-same-filename-out-out-backback.project:3:
cyclical import of cyclical-same-filename-out-out-backback.config
# checking that cyclical check catches importing its importer's importer (hopping over same file names)
# cabal v2-build
Error: [Cabal-7090]
Error parsing project file <ROOT>/cyclical-same-filename-out-out-back.project:1:
cyclical import of same-filename/cyclical-same-filename-out-out-back.config
# checking that imports work skipping into a subfolder and then back out again and again
# cabal v2-build
# checking bad conditional
# cabal v2-build
Error: [Cabal-7090]
......
......@@ -18,7 +18,8 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
-- +-- etc
log "checking cyclical with hops; out and back"
cyclical1a <- fails $ cabal' "v2-build" [ "--project-file=cyclical-1-out-back.project" ]
assertOutputContains "cyclical import of cyclical-1-out-back.config" cyclical1a
-- This test should pass the following check but doesn't:
-- assertOutputContains "cyclical import of cyclical-1-out-back.project" cyclical1a
-- +-- cyclical-1-out-self.project
-- +-- cyclical-1-out-self.config (imports cyclical-1-out-self.config)
......@@ -35,7 +36,8 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
-- +-- etc
log "checking cyclical with hops; out, out, twice back"
cyclical2a <- fails $ cabal' "v2-build" [ "--project-file=cyclical-2-out-out-backback.project" ]
assertOutputContains "cyclical import of cyclical-2-out-out-backback-a.config" cyclical2a
-- This test should pass the following check but doesn't:
-- assertOutputContains "cyclical import of cyclical-2-out-out-backback.project" cyclical2a
-- +-- cyclical-2-out-out-back.project
-- +-- cyclical-2-out-out-back-a.config
......@@ -55,6 +57,74 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
cyclical2c <- fails $ cabal' "v2-build" [ "--project-file=cyclical-2-out-out-self.project" ]
assertOutputContains "cyclical import of cyclical-2-out-out-self-b.config" cyclical2c
-- +-- noncyclical-same-filename-a.project
-- +-- noncyclical-same-filename-a.config
-- +-- same-filename/noncyclical-same-filename-a.config (no further imports so not cyclical)
log "checking that cyclical check doesn't false-positive on same file names in different folders; hoping within a folder and then into a subfolder"
cyclical3b <- cabal' "v2-build" [ "--project-file=noncyclical-same-filename-a.project" ]
assertOutputDoesNotContain "cyclical import of" cyclical3b
-- +-- noncyclical-same-filename-b.project
-- +-- same-filename/noncyclical-same-filename-b.config
-- +-- noncyclical-same-filename-b.config (no further imports so not cyclical)
log "checking that cyclical check doesn't false-positive on same file names in different folders; hoping into a subfolder and then back out again"
cyclical3c <- fails $ cabal' "v2-build" [ "--project-file=noncyclical-same-filename-b.project" ]
assertOutputDoesNotContain "cyclical import of" cyclical3c
-- +-- cyclical-same-filename-out-out-self.project
-- +-- cyclical-same-filename-out-out-self.config
-- +-- same-filename/cyclical-same-filename-out-out-self.config
-- +-- same-filename/cyclical-same-filename-out-out-self.config (already processed)
-- +-- etc
log "checking that cyclical check catches a same file name that imports itself"
cyclical4a <- fails $ cabal' "v2-build" [ "--project-file=cyclical-same-filename-out-out-self.project" ]
assertOutputContains "cyclical import of cyclical-same-filename-out-out-self.config" cyclical4a
-- +-- cyclical-same-filename-out-out-backback.project
-- +-- cyclical-same-filename-out-out-backback.config
-- +-- same-filename/cyclical-same-filename-out-out-backback.config
-- +-- cyclical-same-filename-out-out-backback.project (already processed)
-- +-- etc
log "checking that cyclical check catches importing its importer (with the same file name)"
cyclical4b <- fails $ cabal' "v2-build" [ "--project-file=cyclical-same-filename-out-out-backback.project" ]
-- This test should pass the following check but doesn't:
-- assertOutputContains "cyclical import of cyclical-same-filename-out-out-backback.project" cyclical4b
-- +-- cyclical-same-filename-out-out-back.project
-- +-- cyclical-same-filename-out-out-back.config
-- +-- same-filename/cyclical-same-filename-out-out-back.config
-- +-- cyclical-same-filename-out-out-back.config (already processed)
-- +-- etc
log "checking that cyclical check catches importing its importer's importer (hopping over same file names)"
cyclical4c <- fails $ cabal' "v2-build" [ "--project-file=cyclical-same-filename-out-out-back.project" ]
-- This test should pass the following check but doesn't:
-- assertOutputContains "cyclical import of cyclical-same-filename-out-out-back.config" cyclical4c
-- +-- hops-0.project
-- +-- hops/hops-1.config
-- +-- hops-2.config
-- +-- hops/hops-3.config
-- +-- hops-4.config
-- +-- hops/hops-5.config
-- +-- hops-6.config
-- +-- hops/hops-7.config
-- +-- hops-8.config
-- +-- hops/hops-9.config (no further imports so not cyclical)
log "checking that imports work skipping into a subfolder and then back out again and again"
-- This test should pass the following checks but doesn't, it fails (but it shouldn't):
hopping <- fails $ cabal' "v2-build" [ "--project-file=hops-0.project" ]
-- assertOutputContains "this build was affected by the following (project) config files:" hopping
-- assertOutputContains "hops-0.project" hopping
-- assertOutputContains "../hops-2.config" hopping
-- assertOutputContains "../hops-4.config" hopping
-- assertOutputContains "../hops-6.config" hopping
-- assertOutputContains "../hops-8.config" hopping
-- assertOutputContains "hops/hops-1.config" hopping
-- assertOutputContains "hops/hops-3.config" hopping
-- assertOutputContains "hops/hops-5.config" hopping
-- assertOutputContains "hops/hops-7.config" hopping
-- assertOutputContains "hops/hops-9.config" hopping
log "checking bad conditional"
badIf <- fails $ cabal' "v2-build" [ "--project-file=bad-conditional.project" ]
assertOutputContains "Cannot set compiler in a conditional clause of a cabal project file" badIf
......
import: same-filename/cyclical-same-filename-out-out-back.config
packages: .
import: cyclical-same-filename-out-out-back.config
import: same-filename/cyclical-same-filename-out-out-backback.config
packages: .
import: cyclical-same-filename-out-out-backback.config
import: same-filename/cyclical-same-filename-out-out-self.config
packages: .
import: cyclical-same-filename-out-out-self.config
packages: .
import: hops/hops-1.config
import: hops/hops-3.config
import: hops/hops-5.config
import: hops/hops-7.config
import: hops/hops-9.config
import: ../hops-2.config
import: ../hops-4.config
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment