From a8c7fb5a842031186ad023f9aea8f20619c3e5a4 Mon Sep 17 00:00:00 2001 From: lukaszcl <120112546+lukaszcl@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:50:16 +0200 Subject: [PATCH] Remove repo path from runner --- tools/flakeguard/cmd/run.go | 3 --- tools/flakeguard/runner/runner.go | 11 +++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tools/flakeguard/cmd/run.go b/tools/flakeguard/cmd/run.go index f43d19a29..e73175bd3 100644 --- a/tools/flakeguard/cmd/run.go +++ b/tools/flakeguard/cmd/run.go @@ -15,7 +15,6 @@ var RunTestsCmd = &cobra.Command{ Use: "run", Short: "Run tests to check if they are flaky", Run: func(cmd *cobra.Command, args []string) { - repoPath, _ := cmd.Flags().GetString("repo-path") testPackagesJson, _ := cmd.Flags().GetString("test-packages-json") testPackagesArg, _ := cmd.Flags().GetStringSlice("test-packages") runCount, _ := cmd.Flags().GetInt("run-count") @@ -37,7 +36,6 @@ var RunTestsCmd = &cobra.Command{ runner := runner.Runner{ Verbose: true, - Dir: repoPath, RunCount: runCount, UseRace: useRace, FailFast: failFast, @@ -80,7 +78,6 @@ var RunTestsCmd = &cobra.Command{ } func init() { - RunTestsCmd.Flags().StringP("repo-path", "r", ".", "Path to the Git repository") RunTestsCmd.Flags().String("test-packages-json", "", "JSON-encoded string of test packages") RunTestsCmd.Flags().StringSlice("test-packages", nil, "Comma-separated list of test packages to run") RunTestsCmd.Flags().IntP("run-count", "c", 1, "Number of times to run the tests") diff --git a/tools/flakeguard/runner/runner.go b/tools/flakeguard/runner/runner.go index 45923f633..44268c3cd 100644 --- a/tools/flakeguard/runner/runner.go +++ b/tools/flakeguard/runner/runner.go @@ -14,11 +14,10 @@ import ( ) type Runner struct { - Verbose bool // If true, provides detailed logging. - Dir string // Directory to run commands in. - RunCount int // Number of times to run the tests. - UseRace bool // Enable race detector. - FailFast bool // Stop on first test failure. + Verbose bool // If true, provides detailed logging. + RunCount int // Number of times to run the tests. + UseRace bool // Enable race detector. + FailFast bool // Stop on first test failure. } // RunTests executes the tests for each provided package and aggregates all results. @@ -36,6 +35,7 @@ func (r *Runner) RunTests(packages []string) ([]reports.TestResult, error) { } } + // TODO: make sure the test name includes package name return parseTestResults(jsonOutputs) } @@ -63,7 +63,6 @@ func (r *Runner) runTestPackage(testPackage string) ([]byte, error) { cmd := exec.Command("go", args...) // cmd.Env = append(cmd.Env, "GOFLAGS=-extldflags=-Wl,-ld_classic") // Ensure modules are enabled - cmd.Dir = r.Dir var out bytes.Buffer cmd.Stdout = &out cmd.Stderr = &out