Skip to content

Commit

Permalink
Update to resolver 20.11 (#72)
Browse files Browse the repository at this point in the history
* sed flag -i for MacOS

* Update to resolver 20.11 and necessary changes, including expected results.

* remove macos stuff

* filter architecture specific stuff with sed and change some expected results accordingly.

* Filter architecture specific stuff using stack-root

* Upgrade docker tag

* Update lts to latest

* Remove mac specific sed argument.

---------

Co-authored-by: Erik Hesselink <[email protected]>
  • Loading branch information
mx-ws and hesselink authored May 2, 2023
1 parent 9321a73 commit feaa44e
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM haskell:9.0.1-buster
FROM haskell:9.2.7-buster

RUN apt-get update && \
apt-get install -y jq && \
Expand All @@ -11,7 +11,7 @@ ENV STACK_ROOT=/opt/test-runner/.stack
WORKDIR /opt/test-runner/

COPY pre-compiled/ .
RUN stack build --resolver lts-19.27 --no-terminal --test --no-run-tests
RUN stack build --resolver lts-20.18 --no-terminal --test --no-run-tests

COPY . .
ENTRYPOINT ["/opt/test-runner/bin/run.sh"]
3 changes: 3 additions & 0 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ for test_dir in tests/*; do
test_dir_path=$(realpath "${test_dir}")
results_file_path="${test_dir_path}/results.json"
expected_results_file_path="${test_dir_path}/expected_results.json"
stack_root=$(stack path --stack-root)

bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}"

Expand All @@ -30,6 +31,8 @@ for test_dir in tests/*; do
-e 's/Finished in [0-9]+\.[0-9]+ seconds\\n//' \
-e 's/Completed [0-9]+ action\(s\).\\n//' \
-e "s~${test_dir_path}~/solution~g" \
-e 's/--builddir[^ ]+ //' \
-e "s~${stack_root}/[^ ]+ ~~g" \
"${results_file_path}"

# disable -e since we want all diffs even if one has unexpected
Expand Down
2 changes: 1 addition & 1 deletion bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ set +e

# Run the tests for the provided implementation file and redirect stdout and
# stderr to capture it
test_output=$(stack build --resolver lts-19.27 --test --allow-different-user 2>&1)
test_output=$(stack build --resolver lts-20.18 --test --allow-different-user 2>&1)
exit_code=$?

# re-enable original options
Expand Down
2 changes: 1 addition & 1 deletion pre-compiled/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions pre-compiled/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import LeapYear (isLeapYear)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "isLeapYear" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion src/LeapYear.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module LeapYear (isLeapYear) where

isLeapYear :: Integer -> Bool
isLeapYear year = error "You need to implement this function."
isLeapYear year = error "You need to implement this function."
2 changes: 1 addition & 1 deletion tests/example-all-fail/expected_results.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"status": "fail",
"message": "leap> test (suite: test)\n\n\nisLeapYear\n\u001b[01;31m\u001b[K 2015 - year not divisible by 4 in common year FAILED [1]\u001b[m\u001b[K\n\nFailures:\n\n test/Tests.hs:20:55: \n 1) isLeapYear 2015 - year not divisible by 4 in common year\n expected: False\n but got: True\n\n To rerun use: --match \"/isLeapYear/2015 - year not divisible by 4 in common year/\"\n\n\n1 example, 1 failure\n\nleap> Test suite test failed\nTest suite failure for package leap-1.6.0.10\n test: exited with: ExitFailure 1\nLogs printed to console"
"message": "leap> test (suite: test)\n\n\nisLeapYear\n 2015 - year not divisible by 4 in common year [✘]\n\nFailures:\n\n test/Tests.hs:20:55: \n 1) isLeapYear 2015 - year not divisible by 4 in common year\n expected: False\n but got: True\n\n To rerun use: --match \"/isLeapYear/2015 - year not divisible by 4 in common year/\"\n\n\n1 example, 1 failure\n\nleap> Test suite test failed\n\nError: [S-7282]\n Stack failed to execute the build plan.\n \n While executing the build plan, Stack encountered the following errors:\n \n TestSuiteFailure (PackageIdentifier {pkgName = PackageName \"leap\", pkgVersion = mkVersion [1,6,0,10]}) (fromList [(\"test\",Just (ExitFailure 1))]) Nothing \"\""
}
2 changes: 1 addition & 1 deletion tests/example-all-fail/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions tests/example-all-fail/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import LeapYear (isLeapYear)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "isLeapYear" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion tests/example-empty-file/expected_results.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"status": "fail",
"message": "\n/solution/src/LeapYear.hs:1:1: error:\n File name does not match module name:\n Saw: ‘Main’\n Expected: ‘LeapYear’\n\n-- While building package leap-1.6.0.10 (scroll up to its section to see the error) using:\n /opt/test-runner/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0 build lib:leap test:test --ghc-options \"\"\n Process exited with code: ExitFailure 1"
"message": "\n/solution/src/LeapYear.hs:1:1: error:\n File name does not match module name:\n Saw: ‘Main’\n Expected: ‘LeapYear’\n\nError: [S-7282]\n Stack failed to execute the build plan.\n \n While executing the build plan, Stack encountered the following errors:\n \n [S-7011]\n While building package leap-1.6.0.10 (scroll up to its section to see the error) using:\n --verbose=1 build lib:leap test:test --ghc-options \"\"\n Process exited with code: ExitFailure 1 "
}
2 changes: 1 addition & 1 deletion tests/example-empty-file/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions tests/example-empty-file/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import LeapYear (isLeapYear)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "isLeapYear" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion tests/example-partial-fail/expected_results.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"status": "fail",
"message": "leap> test (suite: test)\n\n\nisLeapYear\n 2015 - year not divisible by 4 in common year\n 1970 - year divisible by 2, not divisible by 4 in common year\n 1996 - year divisible by 4, not divisible by 100 in leap year\n 1960 - year divisible by 4 and 5 is still a leap year\n 2100 - year divisible by 100, not divisible by 400 in common year\n 1900 - year divisible by 100 but not by 3 is still not a leap year\n\u001b[01;31m\u001b[K 2000 - year divisible by 400 in leap year FAILED [1]\u001b[m\u001b[K\n\nFailures:\n\n test/Tests.hs:20:55: \n 1) isLeapYear 2000 - year divisible by 400 in leap year\n expected: True\n but got: False\n\n To rerun use: --match \"/isLeapYear/2000 - year divisible by 400 in leap year/\"\n\n\n7 examples, 1 failure\n\nleap> Test suite test failed\nTest suite failure for package leap-1.6.0.10\n test: exited with: ExitFailure 1\nLogs printed to console"
"message": "leap> test (suite: test)\n\n\nisLeapYear\n 2015 - year not divisible by 4 in common year [✔]\n 1970 - year divisible by 2, not divisible by 4 in common year [✔]\n 1996 - year divisible by 4, not divisible by 100 in leap year [✔]\n 1960 - year divisible by 4 and 5 is still a leap year [✔]\n 2100 - year divisible by 100, not divisible by 400 in common year [✔]\n 1900 - year divisible by 100 but not by 3 is still not a leap year [✔]\n 2000 - year divisible by 400 in leap year [✘]\n\nFailures:\n\n test/Tests.hs:20:55: \n 1) isLeapYear 2000 - year divisible by 400 in leap year\n expected: True\n but got: False\n\n To rerun use: --match \"/isLeapYear/2000 - year divisible by 400 in leap year/\"\n\n\n7 examples, 1 failure\n\nleap> Test suite test failed\n\nError: [S-7282]\n Stack failed to execute the build plan.\n \n While executing the build plan, Stack encountered the following errors:\n \n TestSuiteFailure (PackageIdentifier {pkgName = PackageName \"leap\", pkgVersion = mkVersion [1,6,0,10]}) (fromList [(\"test\",Just (ExitFailure 1))]) Nothing \"\""
}
2 changes: 1 addition & 1 deletion tests/example-partial-fail/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions tests/example-partial-fail/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import LeapYear (isLeapYear)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "isLeapYear" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion tests/example-success/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions tests/example-success/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import LeapYear (isLeapYear)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "isLeapYear" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion tests/example-syntax-error/expected_results.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"status": "fail",
"message": "\n/solution/src/LeapYear.hs:1:7: error: parse error on input ‘@#^&@#’\n |\n1 | module@#^&@# LeapYear2341\n | ^^^^^^\n\n-- While building package leap-1.6.0.10 (scroll up to its section to see the error) using:\n /opt/test-runner/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0 build lib:leap test:test --ghc-options \"\"\n Process exited with code: ExitFailure 1"
"message": "\n/solution/src/LeapYear.hs:1:7: error: parse error on input ‘@#^&@#’\n |\n1 | module@#^&@# LeapYear2341\n | ^^^^^^\n\nError: [S-7282]\n Stack failed to execute the build plan.\n \n While executing the build plan, Stack encountered the following errors:\n \n [S-7011]\n While building package leap-1.6.0.10 (scroll up to its section to see the error) using:\n --verbose=1 build lib:leap test:test --ghc-options \"\"\n Process exited with code: ExitFailure 1 "
}
2 changes: 1 addition & 1 deletion tests/example-syntax-error/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions tests/example-syntax-error/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import LeapYear (isLeapYear)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "isLeapYear" $ for_ cases test
Expand Down

0 comments on commit feaa44e

Please sign in to comment.