-
-
Notifications
You must be signed in to change notification settings - Fork 6
Update elm-test-rs to v2.0 and add smoke tests #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a50f991
Update elm-test-rs to v2.0
jiegillet 174e6dc
Add test_data
jiegillet feecbda
Add smoke tests
jiegillet cc1a459
Fix comment typos
jiegillet 6b6e544
Remove overzealous tests
jiegillet dd62e44
Add smoke tests to CI
jiegillet 31a373d
Some rephrasing
mpizenberg d60edb9
Simplify and merge smoke test scripts
jiegillet 178a111
Remove deleted file from Dockerfile
jiegillet 5a07ddd
Update elm-test-rs to v2.0.1 (unique test names)
mpizenberg b4c7704
Merge branch 'main' into jie-version3
mpizenberg 65c242a
Update smoke tests with task ids, and elm-test-rs 2.0.1
mpizenberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,3 +7,8 @@ | |
| .netlify | ||
|
|
||
| elm-stuff | ||
|
|
||
| # smoke test intermediate files | ||
| test_code.json | ||
| test_results.json | ||
| results.json | ||
This file contains hidden or 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 hidden or 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 hidden or 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,31 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Synopsis: | ||
| # Test the test-runner Docker image by running it against a predefined set of | ||
| # solutions with an expected output. | ||
| # The test-runner Docker image is built automatically. | ||
|
|
||
| # Output: | ||
| # Outputs the diff of the expected test results against the actual test results | ||
| # generated by the test runner Docker image. | ||
|
|
||
| # Example: | ||
| # ./bin/run-tests-in-docker.sh | ||
|
|
||
| set -e # Make script exit when a command fail. | ||
| set -u # Exit on usage of undeclared variable. | ||
| # set -x # Trace what gets executed. | ||
| set -o pipefail # Catch failures in pipes. | ||
|
|
||
| # build docker image | ||
| docker build --rm -t elm-test-runner . | ||
|
|
||
| # run image passing the arguments | ||
| docker run \ | ||
| --rm \ | ||
| --read-only \ | ||
| --network none \ | ||
| --mount type=bind,src=$(realpath test_data),dst=/opt/test-runner/test_data \ | ||
| --mount type=tmpfs,dst=/tmp \ | ||
| --entrypoint /opt/test-runner/bin/smoke_test.sh \ | ||
| elm-test-runner |
This file contains hidden or 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 hidden or 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,36 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -e # Make script exit when a command fail. | ||
| set -u # Exit on usage of undeclared variable. | ||
| # set -x # Trace what gets executed. | ||
| set -o pipefail # Catch failures in pipes. | ||
|
|
||
| for solution in test_data/*/* ; do | ||
| slug=$(basename $(dirname $solution)) | ||
| solution=$(realpath $solution) | ||
|
|
||
| # run tests | ||
| bin/run.sh $slug $solution $solution > /dev/null | ||
|
|
||
| # check result | ||
| if [[ ! -f "${solution}/expected_results.json" ]]; then | ||
| echo "🔥 ${solution}: expected expected_results.json to exist 🔥" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -f "${solution}/results.json" ]]; then | ||
| echo "🔥 ${solution}: expected results.json to exist on successful run 🔥" | ||
| exit 1 | ||
| fi | ||
|
|
||
| jq -S . ${solution}/expected_results.json > /tmp/expected.json | ||
| jq -S . ${solution}/results.json > /tmp/actual.json | ||
| if ! diff /tmp/expected.json /tmp/actual.json ;then | ||
| echo "🔥 ${solution}: expected results.json to equal expected_results.json on successful run 🔥" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "🏁 ${solution}: expected files present and correct after successful run 🏁" | ||
| done | ||
|
|
||
| echo "Smoke test finished" |
This file contains hidden or 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,28 @@ | ||
| { | ||
| "type": "application", | ||
| "source-directories": [ | ||
| "src" | ||
| ], | ||
| "elm-version": "0.19.1", | ||
| "dependencies": { | ||
| "direct": { | ||
| "elm/core": "1.0.5", | ||
| "elm/json": "1.1.3", | ||
| "elm/parser": "1.1.0", | ||
| "elm/random": "1.0.0", | ||
| "elm/regex": "1.0.0", | ||
| "elm/time": "1.0.0" | ||
| }, | ||
| "indirect": {} | ||
| }, | ||
| "test-dependencies": { | ||
| "direct": { | ||
| "elm-explorations/test": "1.2.2", | ||
| "rtfeldman/elm-iso8601-date-strings": "1.1.3" | ||
| }, | ||
| "indirect": { | ||
| "elm/html": "1.0.0", | ||
| "elm/virtual-dom": "1.0.2" | ||
| } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
test_data/lucians-luscious-lasagna/partial_fail/expected_results.json
This file contains hidden or 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,46 @@ | ||
| { | ||
| "version": 3, | ||
| "status": "fail", | ||
| "tests": [ | ||
| { | ||
| "name": "1 > The expected amount of time in the oven is 40 minutes", | ||
| "task_id": 1, | ||
| "status": "fail", | ||
| "message": "\n 40000\n ╷\n │ Expect.equal\n ╵\n 40\n\n", | ||
| "output": null, | ||
| "test_code": "expectedMinutesInOven\n |> Expect.equal 40" | ||
| }, | ||
| { | ||
| "name": "2 > For 2 layers, the preparation time is 4 minutes", | ||
| "task_id": 2, | ||
| "status": "pass", | ||
| "message": null, | ||
| "output": null, | ||
| "test_code": "preparationTimeInMinutes 2\n |> Expect.equal 4" | ||
| }, | ||
| { | ||
| "name": "2 > For 5 layers, the preparation time is 10 minutes", | ||
| "task_id": 2, | ||
| "status": "pass", | ||
| "message": null, | ||
| "output": null, | ||
| "test_code": "preparationTimeInMinutes 5\n |> Expect.equal 10" | ||
| }, | ||
| { | ||
| "name": "3 > For a 3-layers lasagna already in the oven for 10 minutes, you've spent 16 minutes cooking", | ||
| "task_id": 3, | ||
| "status": "pass", | ||
| "message": null, | ||
| "output": null, | ||
| "test_code": "elapsedTimeInMinutes 3 10\n |> Expect.equal 16" | ||
| }, | ||
| { | ||
| "name": "3 > For a 6-layers lasagna already in the oven for 30 minutes, you've spent 42 minutes cooking", | ||
| "task_id": 3, | ||
| "status": "pass", | ||
| "message": null, | ||
| "output": null, | ||
| "test_code": "elapsedTimeInMinutes 6 30\n |> Expect.equal 42" | ||
| } | ||
| ] | ||
| } |
13 changes: 13 additions & 0 deletions
13
test_data/lucians-luscious-lasagna/partial_fail/src/LuciansLusciousLasagna.elm
This file contains hidden or 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,13 @@ | ||
| module LuciansLusciousLasagna exposing (elapsedTimeInMinutes, expectedMinutesInOven, preparationTimeInMinutes) | ||
|
|
||
|
|
||
| expectedMinutesInOven = | ||
| 40000 | ||
|
|
||
|
|
||
| preparationTimeInMinutes layers = | ||
| 2 * layers | ||
|
|
||
|
|
||
| elapsedTimeInMinutes layers passedAlready = | ||
| passedAlready + preparationTimeInMinutes layers |
37 changes: 37 additions & 0 deletions
37
test_data/lucians-luscious-lasagna/partial_fail/tests/Tests.elm
This file contains hidden or 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,37 @@ | ||
| module Tests exposing (tests) | ||
|
|
||
| import Expect | ||
| import LuciansLusciousLasagna exposing (elapsedTimeInMinutes, expectedMinutesInOven, preparationTimeInMinutes) | ||
| import Test exposing (..) | ||
|
|
||
|
|
||
| tests : Test | ||
| tests = | ||
| describe "LuciansLusciousLasagna" | ||
| [ describe "1" | ||
| [ test "The expected amount of time in the oven is 40 minutes" <| | ||
| \_ -> | ||
| expectedMinutesInOven | ||
| |> Expect.equal 40 | ||
| ] | ||
| , describe "2" | ||
| [ test "For 2 layers, the preparation time is 4 minutes" <| | ||
| \_ -> | ||
| preparationTimeInMinutes 2 | ||
| |> Expect.equal 4 | ||
| , test "For 5 layers, the preparation time is 10 minutes" <| | ||
| \_ -> | ||
| preparationTimeInMinutes 5 | ||
| |> Expect.equal 10 | ||
| ] | ||
| , describe "3" | ||
| [ test "For a 3-layers lasagna already in the oven for 10 minutes, you've spent 16 minutes cooking" <| | ||
| \_ -> | ||
| elapsedTimeInMinutes 3 10 | ||
| |> Expect.equal 16 | ||
| , test "For a 6-layers lasagna already in the oven for 30 minutes, you've spent 42 minutes cooking" <| | ||
| \_ -> | ||
| elapsedTimeInMinutes 6 30 | ||
| |> Expect.equal 42 | ||
| ] | ||
| ] |
This file contains hidden or 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,28 @@ | ||
| { | ||
| "type": "application", | ||
| "source-directories": [ | ||
| "src" | ||
| ], | ||
| "elm-version": "0.19.1", | ||
| "dependencies": { | ||
| "direct": { | ||
| "elm/core": "1.0.5", | ||
| "elm/json": "1.1.3", | ||
| "elm/parser": "1.1.0", | ||
| "elm/random": "1.0.0", | ||
| "elm/regex": "1.0.0", | ||
| "elm/time": "1.0.0" | ||
| }, | ||
| "indirect": {} | ||
| }, | ||
| "test-dependencies": { | ||
| "direct": { | ||
| "elm-explorations/test": "1.2.2", | ||
| "rtfeldman/elm-iso8601-date-strings": "1.1.3" | ||
| }, | ||
| "indirect": { | ||
| "elm/html": "1.0.0", | ||
| "elm/virtual-dom": "1.0.2" | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.