feat(test): add --clear-data flag to clear app data on launch

This commit is contained in:
pj committed 2026-04-27 00:51:17 +07:00
1 parent c76745e5f1
commit d489000f63
3 files changed
+5 -1

No files matched your search

+2
View File
@@ -23,6 +23,7 @@ type testOptions struct {
duration time.Duration
seed int64
output string
clearData bool
}
const topUsage = `sanderling is a property-based UI fuzzer for mobile apps.
@@ -51,6 +52,7 @@ func parseTestArgs(args []string, stderr io.Writer) (testOptions, error) {
flagSet.DurationVar(&options.duration, "duration", 5*time.Minute, "total test duration")
flagSet.Int64Var(&options.seed, "seed", 0, "RNG seed (0 = random)")
flagSet.StringVar(&options.output, "output", "./runs", "output directory for traces")
flagSet.BoolVar(&options.clearData, "clear-data", false, "clear app data before launching so the run starts from a fresh install")
if err := flagSet.Parse(args); err != nil {
return testOptions{}, err
}
+1
View File
@@ -17,5 +17,6 @@ func runTestPipeline(ctx context.Context, options testOptions, stdout io.Writer)
Duration: options.duration,
Seed: options.seed,
Output: options.output,
ClearData: options.clearData,
}, stdout)
}
+2 -1
View File
@@ -29,6 +29,7 @@ type Options struct {
Duration time.Duration
Seed int64
Output string
ClearData bool
}
// Execute runs the full test pipeline: bundle, launch app, verify properties.
@@ -68,7 +69,7 @@ func Execute(ctx context.Context, options Options, stdout io.Writer) error {
}
defer cleanup()
if err := activeDriver.Launch(ctx, options.BundleID, false, nil); err != nil {
if err := activeDriver.Launch(ctx, options.BundleID, options.ClearData, nil); err != nil {
return fmt.Errorf("launch app: %w", err)
}