Run

Webtau can run commands in foreground and in background . When command is ran in foreground webtau will wait for the command to finish.To run a command use cli.run with a single string parameter that includes a command and all its arguments: cli.run('echo hello world')

Run With Validation

cli.run('echo hello world') { output.should contain('hello') output.should contain('world') } cli.run('scripts/error-output') { error.should == 'error B892T' } cli.run('scripts/exit-code 8') { exitCode.should == 8 exitCode.shouldNot == 0 }

Implicit Exit Code Validation

Webtau performs implicit exit code validation and adds exitCode equals zero when you don't specify explicit exitCode validation. cli.run('echo hello world') Example above is equivalent to cli.run('echo hello world') { exitCode.should == 0 }

Run Result

Use the result of cli.run if you need to process the output of the command. def result = cli.run('echo hello world') println result.output println result.error if (result.exitCode == 1) { // ... } Warning: Perform validation inside validation block so webtau can track what was checked.

Working Dir

Use cli.workingDir as a second parameter to cli.run to set a working dir: cli.run('./listing', cli.workingDir('../scripts')) { output.should contain('listing files') output.should contain('sleeps') }

Environment Variables

Use cli.env as a second parameter to cli.run to set the environment variables: cli.run('scripts/hello-env-var', cli.env([my_var: 'webtau'])) { output.should == 'hello webtau' }

Chain Cli Run Config

Combine configs by using cli.env(...).workingDir(...) in any order to set both: cli.run('./hello-env-var', cli.workingDir('../scripts').env([my_var: 'webtau'])) { output.should == 'hello webtau' }