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 NoRepl bool
VerboseTest bool = os.Getenv("VERBOSE_TEST") != "" VerboseTest bool = os.Getenv("VERBOSE_TEST") != ""
Tail bool Tail bool
Forcerun bool
) )
// In order to debug CLI running under acceptance test, set this to full subtest name, e.g. "bundle/variables/empty" // 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(&KeepTmp, "keeptmp", false, "Do not delete TMP directory after run")
flag.BoolVar(&NoRepl, "norepl", false, "Do not apply any replacements (for debugging)") 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(&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 ( const (
@ -82,7 +84,7 @@ func TestAccept(t *testing.T) {
} }
func TestInprocessMode(t *testing.T) { func TestInprocessMode(t *testing.T) {
if InprocessMode { if InprocessMode && !Forcerun {
t.Skip("Already tested by TestAccept") t.Skip("Already tested by TestAccept")
} }
require.Equal(t, 1, testAccept(t, true, "selftest/basic")) require.Equal(t, 1, testAccept(t, true, "selftest/basic"))
@ -226,43 +228,47 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
isEnabled, isPresent := config.GOOS[runtime.GOOS] isEnabled, isPresent := config.GOOS[runtime.GOOS]
if isPresent && !isEnabled { if isPresent && !isEnabled {
t.Skipf("Disabled via GOOS.%s setting in %s", runtime.GOOS, configPath) if !Forcerun {
t.Skipf("Disabled via GOOS.%s setting in %s", runtime.GOOS, configPath)
}
} }
cloudEnv := os.Getenv("CLOUD_ENV") cloudEnv := os.Getenv("CLOUD_ENV")
isRunningOnCloud := cloudEnv != "" isRunningOnCloud := cloudEnv != ""
tailOutput := Tail tailOutput := Tail
if isRunningOnCloud { if isRunningOnCloud && isTruePtr(config.CloudSlow) && testing.Verbose() {
if isTruePtr(config.CloudSlow) { // Combination of CloudSlow and -v auto-enables -tail
if testing.Short() { tailOutput = true
t.Skipf("Disabled via CloudSlow setting in %s (CLOUD_ENV=%s, Short=%v)", configPath, cloudEnv, testing.Short()) }
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() { isCloudEnabled := isTruePtr(config.Cloud) || isTruePtr(config.CloudSlow)
// Combination of CloudSlow and -v auto-enables -tail if !isCloudEnabled {
tailOutput = true t.Skipf("Disabled via Cloud/CloudSlow setting in %s (CLOUD_ENV=%s, Cloud=%v, CloudSlow=%v)",
configPath,
cloudEnv,
isTruePtr(config.Cloud),
isTruePtr(config.CloudSlow),
)
} }
}
isCloudEnabled := isTruePtr(config.Cloud) || isTruePtr(config.CloudSlow) if isTruePtr(config.RequiresUnityCatalog) && os.Getenv("TEST_METASTORE_ID") == "" {
if !isCloudEnabled { t.Skipf("Disabled via RequiresUnityCatalog setting in %s (TEST_METASTORE_ID=%s)", configPath, os.Getenv("TEST_METASTORE_ID"))
t.Skipf("Disabled via Cloud/CloudSlow setting in %s (CLOUD_ENV=%s, Cloud=%v, CloudSlow=%v)", }
configPath,
cloudEnv,
isTruePtr(config.Cloud),
isTruePtr(config.CloudSlow),
)
}
if isTruePtr(config.RequiresUnityCatalog) && os.Getenv("TEST_METASTORE_ID") == "" { } else {
t.Skipf("Disabled via RequiresUnityCatalog setting in %s (TEST_METASTORE_ID=%s)", configPath, os.Getenv("TEST_METASTORE_ID")) // Local run
} if !isTruePtr(config.Local) {
t.Skipf("Disabled via Local setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv)
} else { }
// Local run
if !isTruePtr(config.Local) {
t.Skipf("Disabled via Local setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv)
} }
} }