-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests and support for v2 of elm-explorations/test (#118)
* Add tests * Flesh out tests * tweak .gitignore wrt. coverage * Rename test directory * Add kitchensink test Why: to see how multiple coverage reports interact (newlines and all) * Change elm-explorations/test dep to 2.0.0 preemptively * Remove turboMaCk/queue dependency from elm.json * Rename `coverage` to `distribution` * Update elm-test-runner dep to verion 6.0.0 * Update elm-test-rs to v3.0.0 (fuzz distributions support) * Update changelog with info about v3.0 Co-authored-by: Matthieu Pizenberg <[email protected]>
- Loading branch information
1 parent
527020c
commit d8a08a7
Showing
41 changed files
with
605 additions
and
38 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 +1,6 @@ | ||
[package] | ||
name = "elm-test-rs" | ||
version = "2.0.2" | ||
version = "3.0.0" | ||
authors = ["Matthieu Pizenberg <[email protected]>", "Harry Sarson <[email protected]>"] | ||
edition = "2021" | ||
description = "Simple and fast Rust alternative to node-test-runner to run elm tests" | ||
|
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
Submodule elm
updated
8 files
+2 −2 | elm.json | |
+36 −27 | src/ElmTestRunner/Failure.elm | |
+65 −15 | src/ElmTestRunner/Reporter/ConsoleColor.elm | |
+13 −5 | src/ElmTestRunner/Reporter/ConsoleDebug.elm | |
+2 −1 | src/ElmTestRunner/Reporter/Exercism.elm | |
+65 −6 | src/ElmTestRunner/Reporter/Json.elm | |
+45 −10 | src/ElmTestRunner/Reporter/Junit.elm | |
+268 −41 | src/ElmTestRunner/Result.elm |
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
18 changes: 18 additions & 0 deletions
18
tests/example-projects/failing/distribution-expect-failing-distribution/elm.json
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,18 @@ | ||
{ | ||
"type": "package", | ||
"name": "mpizenberg/elm-placeholder-pkg", | ||
"summary": "An empty placeholder package", | ||
"license": "MPL-2.0", | ||
"version": "1.0.0", | ||
"elm-version": "0.19.0 <= v < 0.20.0", | ||
"exposed-modules": [ | ||
"EmptyPlaceholderModule" | ||
], | ||
"dependencies": { | ||
"elm/core": "1.0.0 <= v < 2.0.0" | ||
}, | ||
"test-dependencies": { | ||
"elm/json": "1.1.3 <= v < 2.0.0", | ||
"elm-explorations/test": "2.0.0 <= v < 3.0.0" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/example-projects/failing/distribution-expect-failing-distribution/src/Question.elm
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,14 @@ | ||
module Question exposing (answer) | ||
|
||
|
||
answer : String -> Int | ||
answer question = | ||
let | ||
_ = | ||
Debug.log "The question was" question | ||
in | ||
if question == "What is the Answer to the Ultimate Question of Life, The Universe, and Everything?" then | ||
43 | ||
|
||
else | ||
0 |
25 changes: 25 additions & 0 deletions
25
tests/example-projects/failing/distribution-expect-failing-distribution/tests/Tests.elm
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,25 @@ | ||
module Tests exposing (..) | ||
|
||
import Expect | ||
import Fuzz | ||
import Question | ||
import Test exposing (Test) | ||
import Test.Distribution | ||
|
||
|
||
suite : Test | ||
suite = | ||
Test.fuzzWith | ||
{ runs = 100 | ||
, distribution = | ||
Test.expectDistribution | ||
[ ( Test.Distribution.atLeast 4, "low", \n -> n == 1 ) | ||
, ( Test.Distribution.atLeast 4, "high", \n -> n == 20 ) | ||
, ( Test.Distribution.atLeast 80, "in between", \n -> n > 1 && n < 20 ) | ||
, ( Test.Distribution.zero, "outside", \n -> n < 1 || n > 20 ) | ||
, ( Test.Distribution.zero, "one", \n -> n == 1 ) | ||
] | ||
} | ||
(Fuzz.intRange 1 20) | ||
"Will fail because of distribution demands not met" | ||
(\n -> Expect.pass) |
18 changes: 18 additions & 0 deletions
18
tests/example-projects/failing/distribution-expect-failing-test/elm.json
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,18 @@ | ||
{ | ||
"type": "package", | ||
"name": "mpizenberg/elm-placeholder-pkg", | ||
"summary": "An empty placeholder package", | ||
"license": "MPL-2.0", | ||
"version": "1.0.0", | ||
"elm-version": "0.19.0 <= v < 0.20.0", | ||
"exposed-modules": [ | ||
"EmptyPlaceholderModule" | ||
], | ||
"dependencies": { | ||
"elm/core": "1.0.0 <= v < 2.0.0" | ||
}, | ||
"test-dependencies": { | ||
"elm/json": "1.1.3 <= v < 2.0.0", | ||
"elm-explorations/test": "2.0.0 <= v < 3.0.0" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/example-projects/failing/distribution-expect-failing-test/src/Question.elm
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,14 @@ | ||
module Question exposing (answer) | ||
|
||
|
||
answer : String -> Int | ||
answer question = | ||
let | ||
_ = | ||
Debug.log "The question was" question | ||
in | ||
if question == "What is the Answer to the Ultimate Question of Life, The Universe, and Everything?" then | ||
43 | ||
|
||
else | ||
0 |
25 changes: 25 additions & 0 deletions
25
tests/example-projects/failing/distribution-expect-failing-test/tests/Tests.elm
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,25 @@ | ||
module Tests exposing (..) | ||
|
||
import Expect | ||
import Fuzz | ||
import Question | ||
import Test exposing (Test) | ||
import Test.Distribution | ||
|
||
|
||
suite : Test | ||
suite = | ||
Test.fuzzWith | ||
{ runs = 100 | ||
, distribution = | ||
Test.expectDistribution | ||
[ ( Test.Distribution.atLeast 4, "low", \n -> n == 1 ) | ||
, ( Test.Distribution.atLeast 4, "high", \n -> n == 20 ) | ||
, ( Test.Distribution.atLeast 80, "in between", \n -> n > 1 && n < 20 ) | ||
, ( Test.Distribution.zero, "outside", \n -> n < 1 || n > 20 ) | ||
, ( Test.Distribution.moreThanZero, "one", \n -> n == 1 ) | ||
] | ||
} | ||
(Fuzz.intRange 1 20) | ||
"Will fail because of distribution demands not met" | ||
(\n -> Expect.fail "This test should fail") |
18 changes: 18 additions & 0 deletions
18
tests/example-projects/failing/distribution-not-met/elm.json
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,18 @@ | ||
{ | ||
"type": "package", | ||
"name": "mpizenberg/elm-placeholder-pkg", | ||
"summary": "An empty placeholder package", | ||
"license": "MPL-2.0", | ||
"version": "1.0.0", | ||
"elm-version": "0.19.0 <= v < 0.20.0", | ||
"exposed-modules": [ | ||
"EmptyPlaceholderModule" | ||
], | ||
"dependencies": { | ||
"elm/core": "1.0.0 <= v < 2.0.0" | ||
}, | ||
"test-dependencies": { | ||
"elm/json": "1.1.3 <= v < 2.0.0", | ||
"elm-explorations/test": "2.0.0 <= v < 3.0.0" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/example-projects/failing/distribution-not-met/src/Question.elm
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,14 @@ | ||
module Question exposing (answer) | ||
|
||
|
||
answer : String -> Int | ||
answer question = | ||
let | ||
_ = | ||
Debug.log "The question was" question | ||
in | ||
if question == "What is the Answer to the Ultimate Question of Life, The Universe, and Everything?" then | ||
43 | ||
|
||
else | ||
0 |
25 changes: 25 additions & 0 deletions
25
tests/example-projects/failing/distribution-not-met/tests/Tests.elm
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,25 @@ | ||
module Tests exposing (..) | ||
|
||
import Expect | ||
import Fuzz | ||
import Question | ||
import Test exposing (Test) | ||
import Test.Distribution | ||
|
||
|
||
suite : Test | ||
suite = | ||
Test.fuzzWith | ||
{ runs = 100 | ||
, distribution = | ||
Test.expectDistribution | ||
[ ( Test.Distribution.atLeast 4, "low", \n -> n == 1 ) | ||
, ( Test.Distribution.atLeast 4, "high", \n -> n == 20 ) | ||
, ( Test.Distribution.atLeast 80, "in between", \n -> n > 1 && n < 20 ) | ||
, ( Test.Distribution.zero, "outside", \n -> n < 1 || n > 20 ) | ||
, ( Test.Distribution.zero, "one", \n -> n == 1 ) | ||
] | ||
} | ||
(Fuzz.intRange 1 20) | ||
"Will fail because of distribution demands not met" | ||
(\n -> Expect.pass) |
18 changes: 18 additions & 0 deletions
18
tests/example-projects/failing/distribution-of-failing/elm.json
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,18 @@ | ||
{ | ||
"type": "package", | ||
"name": "mpizenberg/elm-placeholder-pkg", | ||
"summary": "An empty placeholder package", | ||
"license": "MPL-2.0", | ||
"version": "1.0.0", | ||
"elm-version": "0.19.0 <= v < 0.20.0", | ||
"exposed-modules": [ | ||
"EmptyPlaceholderModule" | ||
], | ||
"dependencies": { | ||
"elm/core": "1.0.0 <= v < 2.0.0" | ||
}, | ||
"test-dependencies": { | ||
"elm/json": "1.1.3 <= v < 2.0.0", | ||
"elm-explorations/test": "2.0.0 <= v < 3.0.0" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/example-projects/failing/distribution-of-failing/src/Question.elm
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,14 @@ | ||
module Question exposing (answer) | ||
|
||
|
||
answer : String -> Int | ||
answer question = | ||
let | ||
_ = | ||
Debug.log "The question was" question | ||
in | ||
if question == "What is the Answer to the Ultimate Question of Life, The Universe, and Everything?" then | ||
43 | ||
|
||
else | ||
0 |
23 changes: 23 additions & 0 deletions
23
tests/example-projects/failing/distribution-of-failing/tests/Tests.elm
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,23 @@ | ||
module Tests exposing (..) | ||
|
||
import Expect | ||
import Fuzz | ||
import Question | ||
import Test exposing (Test) | ||
|
||
|
||
suite : Test | ||
suite = | ||
Test.fuzzWith | ||
{ runs = 100 | ||
, distribution = | ||
Test.reportDistribution | ||
[ ( "low", \n -> n == 1 ) | ||
, ( "high", \n -> n == 20 ) | ||
, ( "in between", \n -> n > 1 && n < 20 ) | ||
, ( "outside", \n -> n < 1 || n > 20 ) | ||
] | ||
} | ||
(Fuzz.intRange 1 20) | ||
"Failing test with distribution report" | ||
(\n -> Expect.fail "Test fails no matter what") |
18 changes: 18 additions & 0 deletions
18
tests/example-projects/failing/distribution-report/elm.json
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,18 @@ | ||
{ | ||
"type": "package", | ||
"name": "mpizenberg/elm-placeholder-pkg", | ||
"summary": "An empty placeholder package", | ||
"license": "MPL-2.0", | ||
"version": "1.0.0", | ||
"elm-version": "0.19.0 <= v < 0.20.0", | ||
"exposed-modules": [ | ||
"EmptyPlaceholderModule" | ||
], | ||
"dependencies": { | ||
"elm/core": "1.0.0 <= v < 2.0.0" | ||
}, | ||
"test-dependencies": { | ||
"elm/json": "1.1.3 <= v < 2.0.0", | ||
"elm-explorations/test": "2.0.0 <= v < 3.0.0" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/example-projects/failing/distribution-report/src/Question.elm
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,14 @@ | ||
module Question exposing (answer) | ||
|
||
|
||
answer : String -> Int | ||
answer question = | ||
let | ||
_ = | ||
Debug.log "The question was" question | ||
in | ||
if question == "What is the Answer to the Ultimate Question of Life, The Universe, and Everything?" then | ||
43 | ||
|
||
else | ||
0 |
Oops, something went wrong.