Skip to content

Commit

Permalink
chore: parallelize test by starting subshell (#193)
Browse files Browse the repository at this point in the history
This PR makes `TestStartLocalHelloWorld` start a subshell to clone the
repo, instead of changing the current directory. That allow us to run it
in parallel with the rest.
  • Loading branch information
MegaRedHand authored Jan 22, 2025
1 parent 792ef30 commit 9f28b30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ fmt: kurtosis_fmt cli_fmt ## 🧹 Format all code

lint: kurtosis_lint cli_lint ## 🧹 Lint all code

test: ## 🧪 Run tests
test: examples/hello-world-avs ## 🧪 Run tests
# NOTE: we do this to avoid race conditions in the engine initialization
kurtosis engine start

go test -v -timeout 30m ./...


Expand Down
28 changes: 3 additions & 25 deletions src/cmds/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmds_test
import (
"context"
"os"
"os/exec"
"path/filepath"
"testing"

Expand Down Expand Up @@ -46,23 +45,6 @@ func startDevnet(t *testing.T, devnetConfig config.DevnetConfig, workingDir stri
require.NoError(t, err, "Failed to start new devnet")
}

func goToDir(t *testing.T, destination string) {
dir, err := os.Getwd()
require.NoError(t, err, "Failed to get cwd")

err = os.Chdir(destination)
require.NoError(t, err, "Failed to go to repo root")

t.Cleanup(func() {
// Return to the original directory
err = os.Chdir(dir)
// Panic if failed, to avoid running other tests in the wrong directory
if err != nil {
panic(err)
}
})
}

func TestStartDefaultDevnet(t *testing.T) {
t.Parallel()
startDevnet(t, config.DefaultConfig(), examplesDir)
Expand All @@ -77,13 +59,9 @@ func TestStartIncredibleSquaring(t *testing.T) {
}

func TestStartLocalHelloWorld(t *testing.T) {
// NOTE: we don't run t.Parallel() here because we need to change the working directory
goToDir(t, "../../")

// Clone the hello-world-avs repo
err := exec.Command("make", "examples/hello-world-avs").Run()
require.NoError(t, err, "Failed to make hello-world-avs repo")

// Check that the Hello World AVS repo was downloaded
require.DirExists(t, filepath.Join(examplesDir, "hello-world-avs"), "Hello World AVS repo not found")
t.Parallel()
configFile := filepath.Join(examplesDir, "hello_world_local.yaml")
devnetConfig, err := config.LoadFromPath(configFile)
require.NoError(t, err, "Failed to parse example config")
Expand Down

0 comments on commit 9f28b30

Please sign in to comment.