-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests which check build/dist-newstyle folders are not created wit…
…h v2-run The existing test CmdRun/Script is modified to test the case when v2-run is executed in a project context. This test checks that a "build" folder is not created in the CWD (#10772) A new test is also added which checks what happens in the "no context" case. A separate bug was fixed in this area recently but no test added which verifies the change (#10686)
- Loading branch information
1 parent
6ddbdcf
commit 45e0730
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/NewBuild/CmdRun/NoContext/cabal.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# cabal v2-run | ||
Resolving dependencies... | ||
Build profile: -w ghc-<GHCVER> -O1 | ||
In order, the following will be built: | ||
- fake-package-0 (exe:script-script.hs) (first run) | ||
Configuring executable 'script-script.hs' for fake-package-0... | ||
Building executable 'script-script.hs' for fake-package-0... |
17 changes: 17 additions & 0 deletions
17
cabal-testsuite/PackageTests/NewBuild/CmdRun/NoContext/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
-- NB: Uses cabal_raw' here to direct simulate what a user would write (#10772) | ||
res <- defaultRecordMode RecordMarked $ do | ||
recordHeader ["cabal", "v2-run"] | ||
cabal_raw' ["v2-run", "script.hs", marked_verbose] Nothing | ||
assertOutputContains "Hello World" res | ||
|
||
env <- getTestEnv | ||
cacheDir <- getScriptCacheDirectory (testCurrentDir env </> "script.hs") | ||
liftIO $ print (testTmpDir env </> "build") | ||
|
||
shouldExist $ cacheDir </> "fake-package.cabal" | ||
shouldExist $ cacheDir </> "scriptlocation" | ||
shouldDirectoryNotExist $ testTmpDir env </> "build" | ||
shouldDirectoryNotExist $ testTmpDir env </> "dist-newstyle" |
11 changes: 11 additions & 0 deletions
11
cabal-testsuite/PackageTests/NewBuild/CmdRun/NoContext/script.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env cabal | ||
{- cabal: | ||
build-depends: base >= 4.3 && <5 | ||
-} | ||
{-# LANGUAGE BangPatterns #-} | ||
Check warning on line 5 in cabal-testsuite/PackageTests/NewBuild/CmdRun/NoContext/script.hs
|
||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
import Prelude | ||
|
||
main :: IO () | ||
main = putStrLn "Hello World" |
10 changes: 9 additions & 1 deletion
10
cabal-testsuite/PackageTests/NewBuild/CmdRun/Script/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
res <- cabal' "v2-run" ["script.hs"] | ||
-- NB: Uses cabal_raw' here to direct simulate what a user would write (#10772) | ||
res <- defaultRecordMode RecordMarked $ do | ||
recordHeader ["cabal", "v2-run"] | ||
cabal_raw' ["v2-run", "script.hs", marked_verbose] Nothing | ||
assertOutputContains "Hello World" res | ||
|
||
env <- getTestEnv | ||
cacheDir <- getScriptCacheDirectory (testCurrentDir env </> "script.hs") | ||
liftIO $ print (testTmpDir env </> "build") | ||
|
||
shouldExist $ cacheDir </> "fake-package.cabal" | ||
shouldExist $ cacheDir </> "scriptlocation" | ||
shouldDirectoryNotExist $ testTmpDir env </> "build" | ||
-- "dist-newstyle" should exist, because the folder has a cabal.project in | ||
-- so the v2-run command runs in that context. | ||
shouldDirectoryExist $ testTmpDir env </> "dist-newstyle" |