diff --git a/cmd/sanderling/main.go b/cmd/sanderling/main.go index aafc828..53b49fa 100644 --- a/cmd/sanderling/main.go +++ b/cmd/sanderling/main.go @@ -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 } diff --git a/cmd/sanderling/test_run.go b/cmd/sanderling/test_run.go index a3ffe1c..96d32e1 100644 --- a/cmd/sanderling/test_run.go +++ b/cmd/sanderling/test_run.go @@ -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) } diff --git a/internal/testrun/testrun.go b/internal/testrun/testrun.go index a960fe5..fb25818 100644 --- a/internal/testrun/testrun.go +++ b/internal/testrun/testrun.go @@ -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) }