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 with a single string parameter that includes a command and all its arguments:'echo hello world')

Run With Validation'echo hello world') { output.should contain('hello') output.should contain('world') }'scripts/error-output') { error.should == 'error B892T' }'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.'echo hello world') Example above is equivalent to'echo hello world') { exitCode.should == 0 }

Run Result

Use the result of if you need to process the output of the command. def result ='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. def result ='scripts/generate-id') def id = result.extractFromOutputByRegexp("id=(\\d+)") def result ='scripts/generate-id') def id = result.extractFromErrorByRegexp("id=(\\d+)")

Working Dir

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

Environment Variables

Use cli.env as a second parameter to to set the environment variables:'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:'./hello-env-var', cli.workingDir('../scripts').env([my_var: 'webtau'])) { output.should == 'hello webtau' }


To specify PATH to use for CLI commands lookup use cliPath = ['../scripts/more']

Timeout command fails if it doesn't complete in 30 seconds.To override default timeout use cliTimeout config value: cliTimeout = 400 Note: Timeout value is specified in milliseconds