13.05 - Build-in shortcuts (macros)


# EXECUTE $({command_content}) LOCALLY AS {result}

What: This macro will execute an inline command on the local system. 

# EXECUTE $({command_content}) LOCALLY AS {result}
=>
DEFINE $({command_content}) AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell AS __commandLine{%%rand2}
EXECUTE local WITH __commandLine{%%rand2} AS {result}
ASSERT {result} IS success

Input: 

  • {command_content}: It corresponds to the text of the shell command to execute.
Output:
  • {result}: The name of the resource which references the result of the command.(Resource of category result.shell)

Example:

# EXECUTE_SSH $(echo "hello world") LOCALLY AS result


# EXECUTE $({command_content}) LOCALLY AS {result} WITHIN {timeout} ms

What: This macro will execute an inline command on the local system. 

# EXECUTE $({command_content}) LOCALLY AS {result} WITHIN {timeout} ms
=>
DEFINE $({command_content}) AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell AS __commandLine{%%rand2} USING $(timeout:{timeout})
EXECUTE local WITH __commandLine{%%rand2} AS {result}
ASSERT {result} IS success

Input: 

  • {command_content}: It corresponds to the text of the shell command to execute.
  • {timeout}: Maximal time authorized for the command execution (in milliseconds).
Output:
  • {result}: The name of the resource which references the result of the command. (Resource of category result.shell)

Example:

# EXECUTE $(echo "hello world") LOCALLY AS result WITHIN 15000 ms

# ASSERT {result} IS FAILURE WITH EXIT CODE {exitCode}

What: This macro will verify that the result of a failed execution command contains the expected exit code.

# ASSERT {result} IS FAILURE WITH EXIT CODE {exitCode}
=>

ASSERT {result} IS failure WITH $({exitCode})

Input: 

  • {result}: The resource file that contains the result of a shell execution command (Resource of category result.shell)
  • {exitCode}: The expected return code of the command execution.

Example:

# ASSERT result IS FAILURE WITH EXIT CODE 1


# ASSERT {result} STDOUT CONTAINS {regex}

What: This macro will verify that the standard outflow resulting of a shell command execution contains a specific character string.

# ASSERT {result} STDOUT CONTAINS {regex}
=>

ASSERT {result} DOES contain WITH $({regex}) USING $(out)

Input:

  • {result}: The resource file that contains the result of a shell execution command (Resource of category result.shell)
  • {regex}: The searched character string

Example:

# ASSERT result STDOUT CONTAINS hello world



# ASSERT {result} STDOUT DOES NOT CONTAIN {regex}

What: This macro will verify that the standard outflow resulting of a shell command execution does not contain a specific character string.

# ASSERT {result} STDOUT DOES NOT CONTAIN {regex}
=>

ASSERT {result} DOES not.contain WITH $({regex}) USING $(out)

Input:

  • {result}: The resource file that contains the result of a shell execution command. (Resource of category result.shell)
  • {regex}: The searched character string.

Example:

# ASSERT result STDOUT DOES NOT CONTAIN toto


# ASSERT {result} STDERR CONTAINS {regex}

What: This macro will verify that the error outflow resulting of a shell command execution contains a specific character string.

# ASSERT {result} STDERR CONTAINS {regex}
=>

ASSERT {result} DOES contain WITH $({regex}) USING $(err)

Input:

  • {result}: The resource file that contains the result of a shell execution command. (Resource of category result.shell)
  • {regex}: The searched character string.

Example:

# ASSERT result STDERR CONTAINS hello world


# ASSERT {result} STDERR DOES NOT CONTAIN {regex}

What: This macro will verify that the error outflow resulting of a shell command execution does not contain a specific character string.

# ASSERT {result} STDERR DOES NOT CONTAIN {regex}
=>

ASSERT {result} DOES not.contain WITH $({regex}) USING $(err)

Input:

  • {result}: The resource file that contains the result of a shell execution command. (Resource of category result.shell)
  • {regex}: The searched character string.

Example:

# ASSERT result STDERR DOES NOT CONTAIN toto