Skip to content

Commit b08cab0

Browse files
authored
Flakeguard: Resolve Full Paths for Run Command and Extract Test Parser Module (#1736)
* rename * Move test parser to separate module * fix * Add full path resolution for project and results paths in run command * Use TestGoProjectPath * fix * throw error when no tests were run
1 parent 517eb43 commit b08cab0

File tree

6 files changed

+867
-3
lines changed

6 files changed

+867
-3
lines changed

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
golang 1.24.0

tools/citool/cmd/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ type CITestConf struct {
1212
Path string `yaml:"path" json:"path"`
1313
TestEnvType string `yaml:"test_env_type" json:"test_env_type"`
1414
RunsOn string `yaml:"runs_on" json:"runs_on"`
15-
TestCmd string `yaml:"test_cmd" json:"test_cmd"`
15+
TestGoProjectPath string `yaml:"test_go_project_path" json:"test_go_project_path"` // Root path to the go project with the tests
16+
TestCmd string `yaml:"test_cmd" json:"test_cmd"` // Command to run the test in the TestGoProjectPath
1617
TestConfigOverrideRequired bool `yaml:"test_config_override_required" json:"test_config_override_required"`
1718
TestConfigOverridePath string `yaml:"test_config_override_path" json:"test_config_override_path"`
1819
TestSecretsRequired bool `yaml:"test_secrets_required" json:"test_secrets_required"`

tools/flakeguard/cmd/run.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"fmt"
77
"os"
88
"os/exec"
9+
"time"
910

11+
"github.com/briandowns/spinner"
1012
"github.com/rs/zerolog/log"
1113
"github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard/reports"
1214
"github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard/runner"
@@ -64,6 +66,28 @@ var RunTestsCmd = &cobra.Command{
6466
log.Warn().Err(err).Str("projectPath", goProject).Msg("Failed to get pretty project path")
6567
}
6668

69+
projectPath, err = utils.ResolveFullPath(projectPath)
70+
if err != nil {
71+
log.Error().Err(err).Str("projectPath", projectPath).Msg("Failed to resolve full path for project path")
72+
flushSummaryAndExit(ErrorExitCode)
73+
}
74+
75+
if mainResultsPath != "" {
76+
mainResultsPath, err = utils.ResolveFullPath(mainResultsPath)
77+
if err != nil {
78+
log.Error().Err(err).Str("mainResultsPath", mainResultsPath).Msg("Failed to resolve full path for main results path")
79+
flushSummaryAndExit(ErrorExitCode)
80+
}
81+
}
82+
83+
if rerunResultsPath != "" {
84+
rerunResultsPath, err = utils.ResolveFullPath(rerunResultsPath)
85+
if err != nil {
86+
log.Error().Err(err).Str("rerunResultsPath", rerunResultsPath).Msg("Failed to resolve full path for rerun results path")
87+
flushSummaryAndExit(ErrorExitCode)
88+
}
89+
}
90+
6791
// Retrieve go-test-count flag as a pointer if explicitly provided.
6892
var goTestCountFlag *int
6993
if cmd.Flags().Changed("go-test-count") {
@@ -133,11 +157,15 @@ var RunTestsCmd = &cobra.Command{
133157
// Run the tests
134158
var mainResults []reports.TestResult
135159
if len(testCmdStrings) > 0 {
160+
s := spinner.New(spinner.CharSets[14], 100*time.Millisecond)
161+
s.Suffix = " Running custom test command..."
162+
s.Start()
136163
mainResults, err = testRunner.RunTestCmd(testCmdStrings)
137164
if err != nil {
138165
log.Fatal().Err(err).Msg("Error running custom test command")
139166
flushSummaryAndExit(ErrorExitCode)
140167
}
168+
s.Stop()
141169
} else {
142170
mainResults, err = testRunner.RunTestPackages(testPackages)
143171
if err != nil {
@@ -147,8 +175,8 @@ var RunTestsCmd = &cobra.Command{
147175
}
148176

149177
if len(mainResults) == 0 {
150-
log.Warn().Msg("No tests were run for the specified packages")
151-
flushSummaryAndExit(0)
178+
log.Error().Msg("No tests were run.")
179+
flushSummaryAndExit(ErrorExitCode)
152180
}
153181

154182
// Save the main test results to file

0 commit comments

Comments
 (0)