-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
443 additions
and
41 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
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,12 @@ | ||
# Integration tests | ||
|
||
This directory contains fixtures/assets for integration tests, in which we run | ||
`spago test` on an example program and check that its output is as expected. | ||
|
||
`env-template` contains a skeleton of a PureScript project that will be used as | ||
context for executing examples. | ||
|
||
`cases` contains multiple subdirectories, each representing a test case. Every | ||
test case consists of a `Main.purs` file (containing the test program to be run | ||
via `spago test`) and an `output.txt` file (containing the program's expected | ||
output). |
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,27 @@ | ||
module Test.Main where | ||
|
||
import Prelude | ||
|
||
import Effect (Effect) | ||
import Effect.Aff (Milliseconds(..), delay, launchAff_) | ||
import Test.Spec (describe, it) | ||
import Test.Spec.Assertions (shouldEqual) | ||
import Test.Spec.Reporter (specReporter) | ||
import Test.Spec.Runner (runSpec) | ||
|
||
main :: Effect Unit | ||
main = launchAff_ $ runSpec [specReporter] do | ||
it "one" $ | ||
5 `shouldEqual` (3 + 2) | ||
|
||
describe "two" do | ||
it "first" $ pure unit | ||
it "second" $ pure unit | ||
it "third" $ delay (Milliseconds 20.0) | ||
|
||
describe "three" do | ||
describe "1" do | ||
it "uno" $ pure unit | ||
it "dos" $ pure unit | ||
describe "2" do | ||
it "ein" $ pure unit |
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,12 @@ | ||
[32m✓︎ [0m[2mone[0m | ||
two | ||
[32m✓︎ [0m[2mfirst[0m | ||
[32m✓︎ [0m[2msecond[0m | ||
[32m✓︎ [0m[2mthird[0m | ||
three | ||
1 | ||
[32m✓︎ [0m[2muno[0m | ||
[32m✓︎ [0m[2mdos[0m | ||
2 | ||
[32m✓︎ [0m[2mein[0m | ||
[32m7 passing[0m |
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,26 @@ | ||
module Test.Main where | ||
|
||
import Prelude | ||
|
||
import Effect (Effect) | ||
import Effect.Aff (launchAff_) | ||
import Test.Spec (describe, it) | ||
import Test.Spec.Assertions (fail, shouldEqual) | ||
import Test.Spec.Reporter (specReporter) | ||
import Test.Spec.Runner (runSpec) | ||
|
||
main :: Effect Unit | ||
main = launchAff_ $ runSpec [specReporter] do | ||
it "one" $ | ||
5 `shouldEqual` (3 + 3) | ||
|
||
describe "two" do | ||
it "first" $ fail "boom" | ||
it "second" $ fail "crash" | ||
|
||
describe "three" do | ||
describe "1" do | ||
it "uno" $ fail "ohmigawd" | ||
it "dos" $ fail "aaargh!" | ||
describe "2" do | ||
it "ein" $ fail "die" |
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,24 @@ | ||
[31m1) one[0m | ||
two | ||
[31m2) first[0m | ||
[31m3) second[0m | ||
three | ||
1 | ||
[31m4) uno[0m | ||
[31m5) dos[0m | ||
2 | ||
[31m6) ein[0m | ||
[31m6 failed[0m | ||
|
||
1) one | ||
[31m 5 ≠ 6[0m | ||
2) two first | ||
[31m boom[0m | ||
3) two second | ||
[31m crash[0m | ||
4) three 1 uno | ||
[31m ohmigawd[0m | ||
5) three 1 dos | ||
[31m aaargh![0m | ||
6) three 2 ein | ||
[31m die[0m |
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,26 @@ | ||
module Test.Main where | ||
|
||
import Prelude | ||
|
||
import Effect (Effect) | ||
import Effect.Aff (launchAff_) | ||
import Test.Spec (describe, it) | ||
import Test.Spec.Assertions (fail, shouldEqual) | ||
import Test.Spec.Reporter (specReporter) | ||
import Test.Spec.Runner (runSpec) | ||
|
||
main :: Effect Unit | ||
main = launchAff_ $ runSpec [specReporter] do | ||
it "one" $ | ||
5 `shouldEqual` (3 + 3) | ||
|
||
describe "two" do | ||
it "first" $ pure unit | ||
it "second" $ fail "crash" | ||
|
||
describe "three" do | ||
describe "1" do | ||
it "uno" $ fail "boom" | ||
it "dos" $ pure unit | ||
describe "2" do | ||
it "ein" $ pure unit |
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,19 @@ | ||
[31m1) one[0m | ||
two | ||
[32m✓︎ [0m[2mfirst[0m | ||
[31m2) second[0m | ||
three | ||
1 | ||
[31m3) uno[0m | ||
[32m✓︎ [0m[2mdos[0m | ||
2 | ||
[32m✓︎ [0m[2mein[0m | ||
[32m3 passing[0m | ||
[31m3 failed[0m | ||
|
||
1) one | ||
[31m 5 ≠ 6[0m | ||
2) two second | ||
[31m crash[0m | ||
3) three 1 uno | ||
[31m boom[0m |
26 changes: 26 additions & 0 deletions
26
integration-tests/cases/04-fail-fast-with-timeout/Main.purs
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,26 @@ | ||
module Test.Main where | ||
|
||
import Prelude | ||
|
||
import Data.Maybe (Maybe(..)) | ||
import Effect (Effect) | ||
import Effect.Aff (Milliseconds(..), delay, launchAff_) | ||
import Test.Spec (it) | ||
import Test.Spec.Assertions (shouldEqual) | ||
import Test.Spec.Config (defaultConfig) | ||
import Test.Spec.Reporter (specReporter) | ||
import Test.Spec.Runner (runSpec') | ||
|
||
main :: Effect Unit | ||
main = launchAff_ $ runSpec' config [specReporter] do | ||
it "passes quickly" $ | ||
5 `shouldEqual` (3 + 2) | ||
|
||
it "times out" $ | ||
delay (Milliseconds 15.0) | ||
|
||
it "shouldn't get to run" $ | ||
2 `shouldEqual` 3 | ||
|
||
where | ||
config = defaultConfig { failFast = true, timeout = Just $ Milliseconds 10.0 } |
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,6 @@ | ||
[32m✓︎ [0m[2mpasses quickly[0m | ||
[31m1) times out[0m | ||
[31m1 failed[0m | ||
|
||
1) times out | ||
[31m test timed out after 10ms[0m |
25 changes: 25 additions & 0 deletions
25
integration-tests/cases/05-fail-fast-due-to-test-failure/Main.purs
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 Test.Main where | ||
|
||
import Prelude | ||
|
||
import Effect (Effect) | ||
import Effect.Aff (launchAff_) | ||
import Test.Spec (it) | ||
import Test.Spec.Assertions (fail, shouldEqual) | ||
import Test.Spec.Config (defaultConfig) | ||
import Test.Spec.Reporter (specReporter) | ||
import Test.Spec.Runner (runSpec') | ||
|
||
main :: Effect Unit | ||
main = launchAff_ $ runSpec' config [specReporter] do | ||
it "passes" $ | ||
5 `shouldEqual` (3 + 2) | ||
|
||
it "fails" $ | ||
fail "This is a failing test" | ||
|
||
it "shouldn't get to run" $ | ||
2 `shouldEqual` 3 | ||
|
||
where | ||
config = defaultConfig { failFast = true } |
6 changes: 6 additions & 0 deletions
6
integration-tests/cases/05-fail-fast-due-to-test-failure/output.txt
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,6 @@ | ||
[32m✓︎ [0m[2mpasses[0m | ||
[31m1) fails[0m | ||
[31m1 failed[0m | ||
|
||
1) fails | ||
[31m This is a failing test[0m |
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,7 @@ | ||
let packages = | ||
https://github.com/purescript/package-sets/releases/download/psc-0.15.9-20230629/packages.dhall | ||
|
||
with | ||
spec = (SPEC_REPO_PATH/spago.dhall as Location) | ||
|
||
in packages |
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,5 @@ | ||
{ name = "" | ||
, dependencies = ["aff", "effect", "maybe", "prelude", "spec"] | ||
, packages = ./packages.dhall | ||
, sources = [ "test/**/*.purs" ] | ||
} |
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,5 +1,5 @@ | ||
let upstream = | ||
https://github.com/purescript/package-sets/releases/download/psc-0.15.4-20221229/packages.dhall | ||
sha256:a6af1091425f806ec0da34934bb6c0ab0ac1598620bbcbb60a7d463354e7d87c | ||
https://github.com/purescript/package-sets/releases/download/psc-0.15.9-20230629/packages.dhall | ||
sha256:f91d36c7e4793fe4d7e042c57fef362ff3f9e9ba88454cd38686701e30bf545a | ||
|
||
in upstream |
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,34 @@ | ||
module Test.Spec.Config | ||
( Config | ||
, defaultConfig | ||
) | ||
where | ||
|
||
import Prelude | ||
|
||
import Data.Maybe (Maybe(..)) | ||
import Data.Time.Duration (Milliseconds(..)) | ||
|
||
type Config = | ||
{ slow :: Milliseconds | ||
-- ^ Threshold of time beyond which a test is considered "slow". | ||
|
||
, timeout :: Maybe Milliseconds | ||
-- ^ An optional timeout, applied to each individual test. When omitted, tests | ||
-- are allowed to run forever. | ||
|
||
, exit :: Boolean | ||
-- ^ When `true`, the runner will exit the Node process after running tests. | ||
-- If `false`, the runner will merely return test results. | ||
|
||
, failFast :: Boolean | ||
-- ^ When `true`, first failed test stops the whole run. | ||
} | ||
|
||
defaultConfig :: Config | ||
defaultConfig = | ||
{ slow: Milliseconds 75.0 | ||
, timeout: Just $ Milliseconds 2000.0 | ||
, exit: true | ||
, failFast: false | ||
} |
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
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
Oops, something went wrong.