forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request haskell#7575 from runeksvendsen/ghcjs-build-runner
Restore GHCJS "-build-runner" option
- Loading branch information
Showing
9 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.cabal
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,21 @@ | ||
name: BuildRunner | ||
version: 1.0 | ||
build-type: Simple | ||
cabal-version: >= 1.10 | ||
|
||
test-suite ghcjs-test | ||
type: exitcode-stdio-1.0 | ||
main-is: BuildRunner.hs | ||
build-depends: base | ||
default-language: Haskell2010 | ||
|
||
executable ghcjs-exe | ||
main-is: BuildRunner.hs | ||
build-depends: base | ||
default-language: Haskell2010 | ||
|
||
benchmark ghcjs-bench | ||
type: exitcode-stdio-1.0 | ||
main-is: BuildRunner.hs | ||
build-depends: base | ||
default-language: Haskell2010 |
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.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,7 @@ | ||
module Main where | ||
|
||
import System.Exit (exitSuccess) | ||
|
||
main :: IO () | ||
main = do | ||
exitSuccess |
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,6 @@ | ||
This test verifies that the `-build-runner` option is passed to GHCJS when the cabal commands `test`/`run`/`bench` are run with the `--ghcjs` option. | ||
|
||
This test was created in order to avoid regressions in running GHCJS executables, e.g.: | ||
|
||
* https://github.com/haskell/cabal/issues/6175 | ||
* https://github.com/haskell/cabal/issues/6361 |
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 @@ | ||
packages: . |
19 changes: 19 additions & 0 deletions
19
cabal-testsuite/PackageTests/GHCJS/BuildRunner/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,19 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest . recordMode DoNotRecord $ do | ||
skipIfWindows -- disabled because (I presume) Windows doesn't have BASH | ||
cwd <- fmap testCurrentDir getTestEnv | ||
testInvokedWithBuildRunner cwd "test" [] | ||
testInvokedWithBuildRunner cwd "run" ["ghcjs-exe"] | ||
testInvokedWithBuildRunner cwd "bench" [] | ||
|
||
magicString = "SUCCESS! GHCJS was invoked with '-build-runner' option" | ||
|
||
testInvokedWithBuildRunner cwd cabalCmd extraArgs = do | ||
output <- fails $ cabal' cabalCmd $ extraArgs ++ | ||
[ "--ghcjs" | ||
, "--with-compiler", cwd </> fakeGhcjsPath | ||
] | ||
assertOutputContains magicString output | ||
where | ||
fakeGhcjsPath = "scripts/fake-ghcjs.sh" |
20 changes: 20 additions & 0 deletions
20
cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.sh
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,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# A script that will print out $MAGIC_STRING when invoked with the | ||
# '-build-runner' option. | ||
# | ||
# When cabal is invoked with the '--ghcjs' option and the '--with-compiler' | ||
# option set to the path of this script, cabal will successfully get to the linking | ||
# stage (where it *should* call this script with the '-build-runner' option). | ||
|
||
MAGIC_STRING="SUCCESS! GHCJS was invoked with '-build-runner' option" | ||
|
||
if [ "$1" == "--numeric-ghcjs-version" ]; then | ||
ghc --numeric-version | ||
elif [ "$1" == "--numeric-ghc-version" ]; then | ||
ghc --numeric-version | ||
elif [[ "$*" == *-build-runner* ]]; then | ||
echo "$MAGIC_STRING" | ||
else | ||
ghc "$@" | ||
fi |
9 changes: 9 additions & 0 deletions
9
cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg
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,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ "$1" == "--numeric-ghcjs-version" ]; then | ||
ghc --numeric-version | ||
elif [ "$1" == "--numeric-ghc-version" ]; then | ||
ghc --numeric-version | ||
else | ||
ghc-pkg "$@" | ||
fi |
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,4 @@ | ||
synopsis: Fix running GHCJS executables | ||
packages: cabal-install | ||
prs: #7575 | ||
issues: #6175 #6361 |