Skip to content

Commit

Permalink
support running single test-package
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcl committed Oct 3, 2024
1 parent 9f96240 commit da9c89a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/flakeguard/cmd/run_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ var RunTestsCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
repoPath, _ := cmd.Flags().GetString("repo-path")
testPackagesJson, _ := cmd.Flags().GetString("test-packages-json")
testPackage, _ := cmd.Flags().GetString("test-package")
count, _ := cmd.Flags().GetInt("count")
useRace, _ := cmd.Flags().GetBool("race")
failFast, _ := cmd.Flags().GetBool("fail-fast")

var testPackages []string
if err := json.Unmarshal([]byte(testPackagesJson), &testPackages); err != nil {
fmt.Fprintf(os.Stderr, "Error decoding test packages JSON: %s\n", err)
if testPackagesJson != "" {
if err := json.Unmarshal([]byte(testPackagesJson), &testPackages); err != nil {
fmt.Fprintf(os.Stderr, "Error decoding test packages JSON: %s\n", err)
os.Exit(1)
}
} else if testPackage != "" {
testPackages = append(testPackages, testPackage)
} else {
fmt.Fprintf(os.Stderr, "Error: must specify either --test-packages-json or --test-package\n")
os.Exit(1)
}

Expand All @@ -43,6 +51,7 @@ 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().String("test-package", "", "Single test package to run")
RunTestsCmd.Flags().IntP("count", "c", 1, "Number of times to run the tests")
RunTestsCmd.Flags().Bool("race", false, "Enable the race detector")
RunTestsCmd.Flags().Bool("fail-fast", false, "Stop on the first test failure")
Expand Down

0 comments on commit da9c89a

Please sign in to comment.