Skip to content

Commit

Permalink
feat: allow printing WebDriverAgent output from command line (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbouffard authored Aug 19, 2024
1 parent e42f148 commit 65b068a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Usage:
ios launch <bundleID> [--wait] [--kill-existing] [options]
ios kill (<bundleID> | --pid=<processID> | --process=<processName>) [options]
ios runtest [--bundle-id=<bundleid>] [--test-runner-bundle-id=<testrunnerbundleid>] [--xctest-config=<xctestconfig>] [--log-output=<file>] [--test-to-run=<tests>]... [--test-to-skip=<tests>]... [--env=<e>]... [options]
ios runwda [--bundleid=<bundleid>] [--testrunnerbundleid=<testbundleid>] [--xctestconfig=<xctestconfig>] [--arg=<a>]... [--env=<e>]... [options]
ios runwda [--bundleid=<bundleid>] [--testrunnerbundleid=<testbundleid>] [--xctestconfig=<xctestconfig>] [--log-output=<file>] [--arg=<a>]... [--env=<e>]... [options]
ios ax [--font=<fontSize>] [options]
ios debug [options] [--stop-at-entry] <app_path>
ios fsync (rm [--r] | tree | mkdir) --path=<targetPath>
Expand Down Expand Up @@ -226,7 +226,7 @@ The commands work as following:
> If you provide '-' as log output, it prints resuts to stdout.
> To be able to filter for tests to run or skip, use one argument per test selector. Example: runtest --test-to-run=(TestTarget.)TestClass/testMethod --test-to-run=(TestTarget.)TestClass/testMethod (the value for 'TestTarget' is optional)
> The method name can also be omitted and in this case all tests of the specified class are run
ios runwda [--bundleid=<bundleid>] [--testrunnerbundleid=<testbundleid>] [--xctestconfig=<xctestconfig>] [--arg=<a>]... [--env=<e>]...[options] runs WebDriverAgents
ios runwda [--bundleid=<bundleid>] [--testrunnerbundleid=<testbundleid>] [--xctestconfig=<xctestconfig>] [--log-output=<file>] [--arg=<a>]... [--env=<e>]...[options] runs WebDriverAgents
> specify runtime args and env vars like --env ENV_1=something --env ENV_2=else and --arg ARG1 --arg ARG2
ios ax [--font=<fontSize>] [options] Access accessibility inspector features.
ios debug [--stop-at-entry] <app_path> Start debug with lldb
Expand Down Expand Up @@ -1193,11 +1193,28 @@ func runWdaCommand(device ios.DeviceEntry, arguments docopt.Opts) bool {
}
log.WithFields(log.Fields{"bundleid": bundleID, "testbundleid": testbundleID, "xctestconfig": xctestconfig}).Info("Running wda")

rawTestlog, rawTestlogErr := arguments.String("--log-output")

var writer io.Writer

if rawTestlogErr == nil {
writerCloser := os.Stdout
writer = writerCloser
if rawTestlog != "-" {
file, err := os.Create(rawTestlog)
exitIfError("Cannot open file "+rawTestlog, err)
writer = file
}
defer writerCloser.Close()
} else {
writer = io.Discard
}

errorChannel := make(chan error)
defer close(errorChannel)
ctx, stopWda := context.WithCancel(context.Background())
go func() {
_, err := testmanagerd.RunXCUIWithBundleIdsCtx(ctx, bundleID, testbundleID, xctestconfig, device, wdaargs, wdaenv, nil, nil, testmanagerd.NewTestListener(io.Discard, io.Discard, os.TempDir()))
_, err := testmanagerd.RunXCUIWithBundleIdsCtx(ctx, bundleID, testbundleID, xctestconfig, device, wdaargs, wdaenv, nil, nil, testmanagerd.NewTestListener(writer, writer, os.TempDir()))
if err != nil {
errorChannel <- err
}
Expand Down

0 comments on commit 65b068a

Please sign in to comment.