Skip to content

Commit f3c06ab

Browse files
committed
Add full path resolution for project and results paths in run command
1 parent 7f66f75 commit f3c06ab

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

tools/flakeguard/cmd/run.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,28 @@ var RunTestsCmd = &cobra.Command{
6666
log.Warn().Err(err).Str("projectPath", goProject).Msg("Failed to get pretty project path")
6767
}
6868

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+
6991
// Retrieve go-test-count flag as a pointer if explicitly provided.
7092
var goTestCountFlag *int
7193
if cmd.Flags().Changed("go-test-count") {
@@ -153,7 +175,7 @@ var RunTestsCmd = &cobra.Command{
153175
}
154176

155177
if len(mainResults) == 0 {
156-
log.Warn().Msg("No tests were run for the specified packages")
178+
log.Warn().Msg("No tests were run.")
157179
flushSummaryAndExit(0)
158180
}
159181

tools/flakeguard/utils/utils.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,14 @@ func Deduplicate(items []string) []string {
2828
}
2929
return uniqueItems
3030
}
31+
32+
func ResolveFullPath(projectPath string) (string, error) {
33+
if filepath.IsAbs(projectPath) {
34+
return filepath.Clean(projectPath), nil
35+
}
36+
absPath, err := filepath.Abs(projectPath)
37+
if err != nil {
38+
return "", err
39+
}
40+
return absPath, nil
41+
}

0 commit comments

Comments
 (0)