Skip to content

Commit

Permalink
dev: avoid rerunning unchanged tests
Browse files Browse the repository at this point in the history
Beforehand, running `dev testlogic` would always run all
tests regarldess if they were changed or not, which wastes
time. This PR will check to see which test folders were
modified and only run them if they are modified.

Fixes: #94845
Release note: None
  • Loading branch information
Liam Gillies committed Sep 15, 2023
1 parent defdd31 commit 2ee5472
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/cmd/dev/testlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error {
ignoreCache = true
}

changes, _ := d.exec.CommandContextSilent(ctx, "git", "status")
modifiedTestPrefix := "modified: pkg/"
validChoices := []string{"base", "ccl", "opt", "sqlite", "sqliteccl"}
if len(choices) == 0 {
// Default to all targets if --bigtest, else all non-sqlite targets.
Expand All @@ -105,7 +107,10 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error {
} else {
for _, choice := range validChoices {
if !strings.HasPrefix(choice, "sqlite") {
choices = append(choices, choice)
// Only append if the non-sqlite tests are modified
if strings.Contains(string(changes), modifiedTestPrefix+choice) {
choices = append(choices, choice)
}
}
}
}
Expand Down

0 comments on commit 2ee5472

Please sign in to comment.