summaryrefslogtreecommitdiff
path: root/integration_test.go
diff options
context:
space:
mode:
authorParsa Ghadimi <me@qti3e.com>2018-05-30 17:03:55 +0430
committerRyan Dahl <ry@tinyclouds.org>2018-05-30 08:33:55 -0400
commit2242c6c7921fcb681d3be7683fba862b4954b04a (patch)
tree12a1b50c1e180caafb35a7f37df64aed98e8399d /integration_test.go
parent1156467c937f5b9af532a25fa80a706eea8f959d (diff)
Use wildcard to check stack trace outputs (#3)
Diffstat (limited to 'integration_test.go')
-rw-r--r--integration_test.go32
1 files changed, 10 insertions, 22 deletions
diff --git a/integration_test.go b/integration_test.go
index d98856f37..9f780f0fd 100644
--- a/integration_test.go
+++ b/integration_test.go
@@ -47,7 +47,7 @@ func listTestFiles() []string {
return out
}
-func checkOutput(t *testing.T, outFile string) {
+func checkOutput(t *testing.T, outFile string, shouldSucceed bool) {
outFile = path.Join("testdata", outFile)
jsFile := strings.TrimSuffix(outFile, ".out")
@@ -57,10 +57,12 @@ func checkOutput(t *testing.T, outFile string) {
}
actual, _, err := deno(jsFile)
- if err != nil {
- t.Fatal(err.Error())
+ if shouldSucceed && err != nil {
+ t.Fatalf("Expected success %s", err.Error())
+ } else if !shouldSucceed && err == nil {
+ t.Fatalf("Expected failure but got success")
}
- if bytes.Compare(actual, expected) != 0 {
+ if !patternMatch(string(expected), string(actual)) {
t.Fatalf(`Actual output does not match expected.
-----Actual-------------------
%s-----Expected-----------------
@@ -77,10 +79,9 @@ func deno(inputFn string) (actual []byte, cachedir string, err error) {
cmd := exec.Command(denoFn, "--cachedir="+cachedir, inputFn)
var out bytes.Buffer
cmd.Stdout = &out
+ cmd.Stderr = &out
err = cmd.Run()
- if err == nil {
- actual = out.Bytes()
- }
+ actual = out.Bytes()
return
}
@@ -100,7 +101,8 @@ func TestIntegrationFiles(t *testing.T) {
outFiles := listTestFiles()
for _, outFile := range outFiles {
t.Run(outFile, func(t *testing.T) {
- checkOutput(t, outFile)
+ shouldSucceed := strings.Index(outFile, "error") < 0
+ checkOutput(t, outFile, shouldSucceed)
})
}
}
@@ -133,20 +135,6 @@ func TestIntegrationUrlArgs(t *testing.T) {
}
}
-func TestErrors(t *testing.T) {
- integrationTestSetup()
-
- _, _, err := deno("testdata/013_async_throw.ts")
- if err == nil {
- t.Fatalf("Expected error.")
- }
-
- _, _, err = deno("testdata/007_stack_trace.ts")
- if err == nil {
- t.Fatalf("Expected error.")
- }
-}
-
func TestTestsTs(t *testing.T) {
integrationTestSetup()
// TODO Need unit test for each of the permissions.