mirror of
https://github.com/nmattia/snack.git
synced 2024-11-24 12:16:17 +03:00
Use num of cores as jobs by default
This commit is contained in:
parent
6046a99fcd
commit
1a18526674
24
bin/Snack.hs
24
bin/Snack.hs
@ -171,18 +171,28 @@ discoverPackageFile = do
|
||||
|
||||
-- | How to call @nix-build@
|
||||
newtype NixConfig = NixConfig
|
||||
{ nixNJobs :: Int }
|
||||
{ nixNJobs :: NJobs }
|
||||
|
||||
data NJobs = NJobs Int | NJobsAuto
|
||||
|
||||
nJobsValue :: NJobs -> String
|
||||
nJobsValue = \case
|
||||
NJobs n -> show n
|
||||
NJobsAuto -> "auto"
|
||||
|
||||
parseNixConfig :: Opts.Parser NixConfig
|
||||
parseNixConfig =
|
||||
(NixConfig <$>
|
||||
Opts.option Opts.auto
|
||||
NixConfig <$>
|
||||
(
|
||||
(NJobs <$> Opts.option Opts.auto
|
||||
(Opts.long "jobs"
|
||||
<> Opts.short 'j'
|
||||
<> Opts.value 1
|
||||
<> Opts.metavar "INT"
|
||||
<> Opts.help "How many jobs to run concurrently")
|
||||
)
|
||||
<> Opts.help "How many jobs to run concurrently (default: number of available cores)")
|
||||
) <|>
|
||||
pure NJobsAuto
|
||||
)
|
||||
|
||||
|
||||
--- Snack configuration (unrelated to packages)
|
||||
|
||||
@ -391,7 +401,7 @@ nixBuild snackCfg extraNixArgs nixExpr =
|
||||
[ "-" -- read expression from stdin
|
||||
, "--no-out-link" -- no need for roots
|
||||
-- how many jobs to run concurrently (-j)
|
||||
, "--max-jobs", T.pack (show (nixNJobs nixCfg))
|
||||
, "--max-jobs", T.pack (nJobsValue (nixNJobs nixCfg))
|
||||
] <> (concatMap toCliArgs nixArgs)
|
||||
funArgs :: [String]
|
||||
funArgs = toFunArg <$> nixArgs
|
||||
|
@ -8,6 +8,6 @@ test() {
|
||||
$SNACK run
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -15,4 +15,4 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack" test
|
||||
|
@ -15,4 +15,4 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack" test
|
||||
|
@ -16,5 +16,5 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --snack-nix snack.nix --package-file package.yaml" test
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack --snack-nix snack.nix --package-file package.yaml" test
|
||||
SNACK="snack" test
|
||||
|
@ -15,6 +15,6 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -9,7 +9,7 @@ git clone http://github.com/nmattia/pboy.git $TMP_DIR
|
||||
git -C $TMP_DIR reset --hard a2458d6984930a33a3b1972cb6d5c167d2511b06
|
||||
|
||||
pushd $TMP_DIR
|
||||
snack -j4 build
|
||||
snack build
|
||||
popd
|
||||
|
||||
rm -rf $TMP_DIR
|
||||
|
@ -15,7 +15,7 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.nix -l ../../snack-lib" test
|
||||
# Note: no HPack test, because HPack doesn't support multi library
|
||||
|
@ -17,5 +17,5 @@ test() {
|
||||
|
||||
SNACK="snack" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack --package-file ./package.nix -l ../../snack-lib" test
|
||||
# Note: no HPack test, because HPack doesn't support multi library
|
||||
|
@ -15,5 +15,5 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -15,5 +15,5 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -16,5 +16,5 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -16,5 +16,5 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -8,6 +8,6 @@ test() {
|
||||
$SNACK run
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.nix -l ../../snack-lib" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -8,4 +8,4 @@ test() {
|
||||
$SNACK run -- hello 'this is' 'the answer' bye | diff golden -
|
||||
}
|
||||
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack" test
|
||||
|
@ -8,4 +8,4 @@ test() {
|
||||
$SNACK run
|
||||
}
|
||||
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack" test
|
||||
|
@ -16,5 +16,5 @@ test() {
|
||||
}
|
||||
|
||||
|
||||
SNACK="snack -j4 -p ./package.nix" test
|
||||
SNACK="snack -j4 -p ./package.yaml" test
|
||||
SNACK="snack -p ./package.nix" test
|
||||
SNACK="snack -p ./package.yaml" test
|
||||
|
@ -15,5 +15,5 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack -j4 --package-file ./package.yaml" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
||||
|
@ -11,4 +11,4 @@ test() {
|
||||
diff golden.jq $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack" test
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
snack -j4 build --package-file code/package.nix
|
||||
snack -j4 run --package-file code/package.nix | diff golden -
|
||||
snack build --package-file code/package.nix
|
||||
snack run --package-file code/package.nix | diff golden -
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
capture_io "$TMP_FILE" main | snack -j4 --package-file code/package.nix ghci
|
||||
capture_io "$TMP_FILE" main | snack --package-file code/package.nix ghci
|
||||
|
||||
diff golden $TMP_FILE
|
||||
rm $TMP_FILE
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
snack -j4 build
|
||||
snack -j4 run | diff golden -
|
||||
snack build
|
||||
snack run | diff golden -
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
capture_io "$TMP_FILE" main | snack -j4 ghci
|
||||
capture_io "$TMP_FILE" main | snack ghci
|
||||
|
||||
diff golden $TMP_FILE
|
||||
rm $TMP_FILE
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
snack -j4 build
|
||||
snack -j4 run | diff golden -
|
||||
snack build
|
||||
snack run | diff golden -
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
capture_io "$TMP_FILE" main | snack -j4 ghci
|
||||
capture_io "$TMP_FILE" main | snack ghci
|
||||
|
||||
diff golden $TMP_FILE
|
||||
rm $TMP_FILE
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
snack -j4 build
|
||||
snack -j4 run | diff golden -
|
||||
snack build
|
||||
snack run | diff golden -
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
capture_io "$TMP_FILE" main | snack -j4 ghci
|
||||
capture_io "$TMP_FILE" main | snack ghci
|
||||
|
||||
diff golden $TMP_FILE
|
||||
rm $TMP_FILE
|
||||
|
@ -15,6 +15,6 @@ test() {
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack -j4" test
|
||||
SNACK="snack -j4 --package-file ./package.nix" test
|
||||
SNACK="snack" test
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
# Note: no HPack test, because HPack doesn't support multi library
|
||||
|
Loading…
Reference in New Issue
Block a user