forked from PaulDance/xr
-
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.
Implement stack resolver override for Haskell.
Closes PaulDance#13. This patch also bundled some other changes: - `-Wall` to `--ghc-options -Wall` as this is supposed to be pased to GHC (stack can't recognize this flag) - Removed `--trace` as it tends to be verbose and messes up hspec's output.
- Loading branch information
Showing
2 changed files
with
31 additions
and
2 deletions.
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
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,10 +1,33 @@ | ||
function _override_stack_resolver() { | ||
if [[ -z "$XR_HASKELL_STACK_RESOLVER" ]]; then | ||
return | ||
fi | ||
|
||
# See https://docs.haskellstack.org/en/stable/pantry/#snapshot-location for resolver syntax. | ||
# For the purpose of running exercises it's resonable just to allow lts and nightly. | ||
if ! [[ $XR_HASKELL_STACK_RESOLVER =~ '^(lts-[0-9\.]+|nightly-[0-9-]+)$' ]]; then | ||
echo Skipped resolver override as $XR_HASKELL_STACK_RESOLVER is not allowed. | ||
return | ||
fi | ||
|
||
if ! stack --resolver="$XR_HASKELL_STACK_RESOLVER" eval '()' >/dev/null 2>/dev/null; then | ||
echo Skipped resolver override as stack cannot recognize $XR_HASKELL_STACK_RESOLVER. | ||
return | ||
fi | ||
|
||
echo Overriding resolver to $XR_HASKELL_STACK_RESOLVER. | ||
sed -i 's/resolver: .*/resolver: '"$XR_HASKELL_STACK_RESOLVER"'/' stack.yaml | ||
} | ||
|
||
# Runs all the available tests. | ||
function _run_tests() { | ||
stack test -Wall --trace \ | ||
_override_stack_resolver | ||
stack test --ghc-options -Wall \ | ||
&& hlint . | ||
} | ||
|
||
# Just runs any available benchmark, importing still needs to be added. | ||
function _run_benches() { | ||
stack bench -Wall --no-run-tests | ||
_override_stack_resolver | ||
stack bench --ghc-options -Wall --no-run-tests | ||
} |