acc: add -forcerun flag (#2480)

If set, all skip directives are ignored.

It is useful to run test on OS / Cloud where it is not normally enabled
without having to edit test.toml
This commit is contained in:
Denis Bilenko 2025-03-14 10:25:42 +01:00 committed by GitHub
parent b2c87ae5d0
commit d9695fe1e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 27 deletions

View File

@ -39,6 +39,7 @@ var (
NoRepl bool
VerboseTest bool = os.Getenv("VERBOSE_TEST") != ""
Tail bool
Forcerun bool
)
// In order to debug CLI running under acceptance test, set this to full subtest name, e.g. "bundle/variables/empty"
@ -56,6 +57,7 @@ func init() {
flag.BoolVar(&KeepTmp, "keeptmp", false, "Do not delete TMP directory after run")
flag.BoolVar(&NoRepl, "norepl", false, "Do not apply any replacements (for debugging)")
flag.BoolVar(&Tail, "tail", false, "Log output of script in real time. Use with -v to see the logs: -tail -v")
flag.BoolVar(&Forcerun, "forcerun", false, "Force running the specified tests, ignore all reasons to skip")
}
const (
@ -82,7 +84,7 @@ func TestAccept(t *testing.T) {
}
func TestInprocessMode(t *testing.T) {
if InprocessMode {
if InprocessMode && !Forcerun {
t.Skip("Already tested by TestAccept")
}
require.Equal(t, 1, testAccept(t, true, "selftest/basic"))
@ -226,23 +228,26 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
isEnabled, isPresent := config.GOOS[runtime.GOOS]
if isPresent && !isEnabled {
if !Forcerun {
t.Skipf("Disabled via GOOS.%s setting in %s", runtime.GOOS, configPath)
}
}
cloudEnv := os.Getenv("CLOUD_ENV")
isRunningOnCloud := cloudEnv != ""
tailOutput := Tail
if isRunningOnCloud && isTruePtr(config.CloudSlow) && testing.Verbose() {
// Combination of CloudSlow and -v auto-enables -tail
tailOutput = true
}
if !Forcerun {
if isRunningOnCloud {
if isTruePtr(config.CloudSlow) {
if testing.Short() {
t.Skipf("Disabled via CloudSlow setting in %s (CLOUD_ENV=%s, Short=%v)", configPath, cloudEnv, testing.Short())
}
if testing.Verbose() {
// Combination of CloudSlow and -v auto-enables -tail
tailOutput = true
}
}
isCloudEnabled := isTruePtr(config.Cloud) || isTruePtr(config.CloudSlow)
@ -265,6 +270,7 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
t.Skipf("Disabled via Local setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv)
}
}
}
id := uuid.New()
uniqueName := strings.Trim(base32.StdEncoding.EncodeToString(id[:]), "=")