From 8b15f22379fec618faf2c2b6ce8bdb783afd6c4e Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Fri, 26 May 2023 19:04:11 +1000 Subject: [PATCH] WIP --- .vscode/tasks.json | 6 +++--- pkg/integration/clients/go_test.go | 5 ++--- pkg/integration/components/assertion_helper.go | 2 +- pkg/integration/result/result.go | 8 +++++--- pkg/integration/tests/commit/commit.go | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 8027a5344..0bcc9eab2 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -24,7 +24,7 @@ { "label": "Run current file integration test", "type": "shell", - "command": "go generate pkg/integration/tests/tests.go && go run cmd/integration_test/main.go cli ${relativeFile}", + "command": "go run cmd/integration_test/main.go cli ${relativeFile}", "problemMatcher": [], "group": { "kind": "test", @@ -37,7 +37,7 @@ { "label": "Run current file integration test (slow)", "type": "shell", - "command": "go generate pkg/integration/tests/tests.go && go run cmd/integration_test/main.go cli --slow ${relativeFile}", + "command": "go run cmd/integration_test/main.go cli --slow ${relativeFile}", "problemMatcher": [], "group": { "kind": "test", @@ -49,7 +49,7 @@ { "label": "Run current file integration test (sandbox)", "type": "shell", - "command": "go generate pkg/integration/tests/tests.go && go run cmd/integration_test/main.go cli --sandbox ${relativeFile}", + "command": "go run cmd/integration_test/main.go cli --sandbox ${relativeFile}", "problemMatcher": [], "group": { "kind": "test", diff --git a/pkg/integration/clients/go_test.go b/pkg/integration/clients/go_test.go index 1f4028ffb..07e27f968 100644 --- a/pkg/integration/clients/go_test.go +++ b/pkg/integration/clients/go_test.go @@ -29,8 +29,6 @@ func TestIntegration(t *testing.T) { tests := tests.GetTests() - tests = tests[0:3] - err := components.RunTests( tests, t.Logf, @@ -46,7 +44,7 @@ func TestIntegration(t *testing.T) { // } t.Run(test.Name(), func(t *testing.T) { - // t.Parallel() + t.Parallel() err := f() assert.NoError(t, err) }) @@ -98,6 +96,7 @@ func runCmdHeadless(cmd *exec.Cmd) error { if !result.Success { return errors.New(result.Message) } + fmt.Printf("test succeeded") return nil } diff --git a/pkg/integration/components/assertion_helper.go b/pkg/integration/components/assertion_helper.go index 9bc41a4d6..d4daf3ab0 100644 --- a/pkg/integration/components/assertion_helper.go +++ b/pkg/integration/components/assertion_helper.go @@ -18,7 +18,7 @@ func retryWaitTimes() []int { // give it more leeway compared to when we're running things locally. return []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000} } else { - return []int{0, 1, 1, 1, 1, 1} + return []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000} } } diff --git a/pkg/integration/result/result.go b/pkg/integration/result/result.go index 7f0bbe1d1..203259ec8 100644 --- a/pkg/integration/result/result.go +++ b/pkg/integration/result/result.go @@ -40,7 +40,9 @@ func success() IntegrationTestResult { func writeResult(result IntegrationTestResult) error { resultPath := os.Getenv(PathEnvVar) if resultPath == "" { - return fmt.Errorf("Environment variable %s not set", PathEnvVar) + panic("path env var not set!") + // path env var not set so we'll assume we don't need to write the result to a file + return nil } file, err := os.Create(resultPath) @@ -62,7 +64,7 @@ func writeResult(result IntegrationTestResult) error { func ReadResult(resultPath string) (IntegrationTestResult, error) { file, err := os.Open(resultPath) if err != nil { - return IntegrationTestResult{}, fmt.Errorf("Error creating file: %w", err) + return IntegrationTestResult{}, fmt.Errorf("Error reading file: %w", err) } decoder := json.NewDecoder(file) @@ -74,7 +76,7 @@ func ReadResult(resultPath string) (IntegrationTestResult, error) { } file.Close() - _ = os.Remove(resultPath) + // _ = os.Remove(resultPath) return result, nil } diff --git a/pkg/integration/tests/commit/commit.go b/pkg/integration/tests/commit/commit.go index 0a62e0ccb..b8edc8ba6 100644 --- a/pkg/integration/tests/commit/commit.go +++ b/pkg/integration/tests/commit/commit.go @@ -55,7 +55,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{ IsFocused(). Lines( Contains("A myfile"), - Contains("A myfile2"), + Contains("A myfile3"), ) }, })