Buildspec Overview

What is a buildspec?

A buildspec is a YAML file that defines your test in buildtest which is validated by schema followed by building a shell script and running the generated test. Buildtest will parse the buildspec with the global schema file which defines the top-level structure of buildspec file.

Example

Let’s start off with a simple example that declares two variables X and Y and prints the sum of X+Y.

buildspecs:
  add_numbers:
    type: script
    executor: generic.local.bash
    description: Add X+Y
    tags: [tutorials]
    vars:
      X: 1
      Y: 2
    run: echo "$X+$Y=" $(($X+$Y))

buildtest will validate the entire file with global.schema.json, the schema requires version and buildspec in order to validate file. The buildspec is where you define each test. The name of the test is add_numbers. The test requires a type field which is the sub-schema used to validate the test section. In this example type: script informs buildtest to use the Script Schema when validating test section.

Each subschema has a list of field attributes that are supported, for example the fields: type, executor, vars and run are all valid fields supported by the script schema.

Let’s look at a more interesting example, shown below is a multi line run example using the script schema with test name called systemd_default_target, shown below is the content of test:

buildspecs:
  systemd_default_target:
    executor: generic.local.bash
    type: script
    tags: [system]
    description: check if default target is multi-user.target
    run: |
      if [ "multi-user.target" == `systemctl get-default` ]; then
        echo "multi-user is the default target";
        exit 0
      fi
      echo "multi-user is not the default target";
      exit 1

The test name systemd_default_target defined in buildspec section is validated with the following pattern "^[A-Za-z_][A-Za-z0-9_]*$". This test will use the executor generic.local.bash which means it will use the Local Executor with an executor name bash defined in the buildtest settings. The default buildtest settings will provide a bash executor as follows:

system:
  generic:
    hostnames: ["localhost"]
    executors:
      local:
        bash:
          description: submit jobs on local machine using bash shell
          shell: bash

The shell: bash indicates this executor will use bash to run the test scripts. To reference this executor use the format <system>.<type>.<name> in this case generic.local.bash refers to bash executor.

The description field is an optional key that can be used to provide a brief summary of the test. The description field is limited to 80 characters. In this example we can specify multiple commands in run section, this can be done in YAML using run: | followed by content of run section tab indented 2 spaces.

In this next example, we introduce the summary field, which can be used as an extended description of test. It has no impact on the test. Unlike the description field, the summary field has no limit on character count and one can define multi-line string using the pipe symbol |.

buildspecs:
  summary_example:
    type: script
    executor: generic.local.bash
    description: The summary field can be a multi-line string and exceed 80 char
    tags: [tutorials]
    summary: |
      This is a long description of test that
      can exceed 80 characters and be multiline
    run: hostname

Script Schema

The script schema is used for writing simple scripts (bash, sh, python) in Buildspec. To use this schema you must set type: script. The run field is responsible for writing the content of test.

Shown below is schema header for script.schema.json.

{
  "$id": "script.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "script schema version",
  "description": "The script schema is of ``type: script`` in sub-schema which is used for running shell scripts",
  "type": "object",
  "required": [
    "type",

The "type": "object" means sub-schema is a JSON object where we define a list of key/value pair. The "required" field specifies a list of fields that must be specified in order to validate the Buildspec. In this example, type, run, and executor are required fields. The additionalProperties: false informs schema to reject any extra properties not defined in the schema.

The executor key is required for all sub-schemas which instructs buildtest which executor to use when running the test. The executors are defined in Configuring buildtest. In our first example we define variables using the vars property which is a Key/Value pair for variable assignment. The run section is required for script schema which defines the content of the test script.

For more details on script schema see schema docs at https://buildtesters.github.io/buildtest/

Declaring Environment Variables

You can define environment variables using the env property, this is compatible with shells: bash, sh, zsh, csh and tcsh. It does not work with shell: python. In example below we declare three tests using environment variable with default shell (bash), csh, and tcsh

buildspecs:
  bash_env_variables:
    executor: generic.local.bash
    description: Declare environment variables in default shell (bash)
    type: script
    env:
      FIRST_NAME: avocado
      LAST_NAME: dinosaur
    tags: [tutorials]
    run: |
      hostname
      whoami
      echo $USER
      printf "${FIRST_NAME} ${LAST_NAME}\n"

  csh_env_declaration:
    executor: generic.local.csh
    type: script
    description: "csh shell example to declare environment variables"
    shell: /bin/csh
    tags: [tutorials]
    env:
      SHELL_NAME: "csh"
    run: echo "This is running $SHELL_NAME"

  tcsh_env_declaration:
    executor: generic.local.csh
    type: script
    description: "tcsh shell example to declare environment variables"
    shell: /bin/tcsh
    tags: [tutorials]
    env:
      path: "/usr/local/bin:$PATH"
    run: echo $path

This test can be run by issuing the following command: buildtest build -b tutorials/environment.yml. If we inspect one of the test script we will see that buildtest generates a build script that invokes the test using the shell wrapper /bin/csh for the csh test and gets the returncode.

#!/bin/bash


############# START VARIABLE DECLARATION ########################
export BUILDTEST_TEST_NAME=csh_env_declaration
export BUILDTEST_TEST_ROOT=/Users/siddiq90/Documents/GitHubDesktop/buildtest/var/tests/generic.local.csh/environment/csh_env_declaration/0
export BUILDTEST_BUILDSPEC_DIR=/Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials
export BUILDTEST_STAGE_DIR=/Users/siddiq90/Documents/GitHubDesktop/buildtest/var/tests/generic.local.csh/environment/csh_env_declaration/0/stage
export BUILDTEST_TEST_ID=501ec5d3-e614-4ae8-9c1e-4849ce340c76
############# END VARIABLE DECLARATION   ########################


# source executor startup script
source /Users/siddiq90/Documents/GitHubDesktop/buildtest/var/executor/generic.local.csh/before_script.sh
# Run generated script
/bin/csh /Users/siddiq90/Documents/GitHubDesktop/buildtest/var/tests/generic.local.csh/environment/csh_env_declaration/0/stage/csh_env_declaration.csh
# Get return code
returncode=$?
# Exit with return code
exit $returncode

This generated test looks something like this

#!/bin/csh
# Declare environment variables
setenv SHELL_NAME csh


# Content of run section
echo "This is running $SHELL_NAME"

Environment variables are defined using export in bash, sh, zsh while csh and tcsh use setenv.

Declaring Variables

Variables can be defined using vars property, this is compatible with all shells except for python. The variables are defined slightly different in csh, tcsh as pose to bash, sh, and zsh. In example below we define tests with bash and csh.

In YAML strings can be specified with or without quotes however in bash, variables need to be enclosed in quotes " if you are defining a multi word string (name="First Last").

If you need define a literal string it is recommended to use the literal block | that is a special character in YAML. If you want to specify " or ' in string you can use the escape character \ followed by any of the special character. In example below we define several variables such as X, Y that contain numbers, variable literalstring is a literal string processed by YAML. The variable singlequote and doublequote defines a variable with the special character ' and ". The variables current_user and num_files store result of a shell command. This can be done using var=$(<command>) or var=`<command>` where <command> is a Linux command.

buildspecs:
  variables_bash:
    type: script
    executor: generic.local.bash
    description: Declare shell variables in bash
    tags: [tutorials]
    vars:
      X: 1
      Y: 2
      literalstring: this is a literal string
      singlequote: \'singlequote\'
      doublequote: \"doublequote\"
      current_user: "$(whoami)"
      num_files: "`find $HOME -type f -maxdepth 1 | wc -l`"
      multiline_string: |
        Hello my name is Bob \n
        I am 30 years old


    run: |
      echo "$X+$Y="$(($X+$Y))
      echo $literalstring
      echo $singlequote
      echo $doublequote
      echo "current user:" $current_user
      echo "number of files:" $num_files
      echo -e $multiline_string

Next we build this test by running buildtest build -b $BUILDTEST_ROOT/tutorials/vars.yml.

$ buildtest build -b $BUILDTEST_ROOT/tutorials/vars.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:30                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/vars.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 1
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ variables… │ generic.l… │ None     │ None  │ None  │ Declare    │ /home/doc… │
│            │            │          │       │       │ shell      │            │
│            │            │          │       │       │ variables  │            │
│            │            │          │       │       │ in bash    │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
variables_bash/b3af6e1b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b
variables_bash/b3af6e1b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/stage
variables_bash/b3af6e1b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/variables_bash_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
variables_bash/b3af6e1b does not have any dependencies adding test to queue
variables_bash/b3af6e1b: Running Test via command: bash --norc --noprofile -eo pipefail variables_bash_build.sh
variables_bash/b3af6e1b: Test completed in 0.010571 seconds
variables_bash/b3af6e1b: Test completed with returncode: 0
variables_bash/b3af6e1b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/variables_bash.out
variables_bash/b3af6e1b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/variables_bash.err
In this iteration we are going to run the following tests: [variables_bash/b3af6e1b]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ variables_ba │ generic.loc… │ PASS   │ N/A N/A N/A   │ 0          │ 0.010571 │
│ sh/b3af6e1b  │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%


Adding 1 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest__f9uxkxe.log

Let’s check the generated script from the previous build, you can run buildtest inspect query -o variables_bash where -o refers to output file for testname variables_bash. Take note of the output file we

$ buildtest inspect query -o variables_bash
───────────── variables_bash/b3af6e1b-8531-48d0-8176-abbc88cca4cf ──────────────
Executor: generic.local.bash
Description: Declare shell variables in bash
State: PASS
Returncode: 0
Runtime: 0.010571 sec
Starttime: 2022/08/17 19:19:30
Endtime: 2022/08/17 19:19:30
Command: bash --norc --noprofile -eo pipefail variables_bash_build.sh
Test Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/variables_bash.sh
Build Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/variables_bash_build.sh
Output File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/variables_bash.out
Error File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/vars/variables_bash/b3af6e1b/variables_bash.err
Log File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest__f9uxkxe.log
─ Output File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/che… ─
1+2=3                                                                           
this is a literal string                                                        
\'singlequote\'                                                                 
"doublequote"                                                                   
current user: docs                                                              
number of files: 4                                                              
Hello my name is Bob                                                            
 I am 30 years old

Test Status

buildtest will record state of each test which can be PASS or FAIL. By default a 0 exit code is PASS and everything else is a FAIL. The status property can be used to determine how test will report its state. Currently, we can match state based on returncode, runtime, or regular expression.

Return Code Matching

buildtest can report PASS/FAIL based on returncode, by default a 0 exit code is PASS and everything else is FAIL. The returncode can be a list of exit codes to match. In this example we have four tests called exit1_fail, exit1_pass, returncode_list_mismatch and returncode_int_match. We expect exit1_fail and returncode_mismatch to FAIL while exit1_pass and returncode_int_match will PASS.

buildspecs:

  exit1_fail:
    executor: generic.local.bash
    type: script
    description: exit 1 by default is FAIL
    tags: [tutorials, fail]
    run: exit 1

  exit1_pass:
    executor: generic.local.bash
    type: script
    description: report exit 1 as PASS
    run: exit 1
    tags: [tutorials, pass]
    status:
      returncode: [1]

  returncode_list_mismatch:
    executor: generic.local.bash
    type: script
    description: exit 2 failed since it failed to match returncode 1
    run: exit 2
    tags: [tutorials, fail]
    status:
      returncode: [1, 3]

  returncode_int_match:
    executor: generic.local.bash
    type: script
    description: exit 128 matches returncode 128
    run: exit 128
    tags: [tutorials, pass]
    status:
      returncode: 128

Let’s build this test and pay close attention to the status column in output.

$ buildtest build -b tutorials/test_status/pass_returncode.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:31                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/test_status/pass_returncode.yml: VALID
Total builder objects created: 4
Total compiler builder: 0
Total script builder: 4
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ exit1_fai… │ generic.l… │ None     │ None  │ None  │ exit 1 by  │ /home/doc… │
│            │            │          │       │       │ default is │            │
│            │            │          │       │       │ FAIL       │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ exit1_pas… │ generic.l… │ None     │ None  │ None  │ report     │ /home/doc… │
│            │            │          │       │       │ exit 1 as  │            │
│            │            │          │       │       │ PASS       │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ returncod… │ generic.l… │ None     │ None  │ None  │ exit 2     │ /home/doc… │
│            │            │          │       │       │ failed     │            │
│            │            │          │       │       │ since it   │            │
│            │            │          │       │       │ failed to  │            │
│            │            │          │       │       │ match      │            │
│            │            │          │       │       │ returncode │            │
│            │            │          │       │       │ 1          │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ returncod… │ generic.l… │ None     │ None  │ None  │ exit 128   │ /home/doc… │
│            │            │          │       │       │ matches    │            │
│            │            │          │       │       │ returncode │            │
│            │            │          │       │       │ 128        │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
exit1_fail/0566208b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_fail/0566208b
exit1_fail/0566208b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_fail/0566208b/stage
exit1_fail/0566208b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_fail/0566208b/exit1_fail_build.sh
exit1_pass/d7846bbb: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_pass/d7846bbb
exit1_pass/d7846bbb: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_pass/d7846bbb/stage
exit1_pass/d7846bbb: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_pass/d7846bbb/exit1_pass_build.sh
returncode_list_mismatch/91593376: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_list_mismatch/91593376
returncode_list_mismatch/91593376: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_list_mismatch/91593376/stage
returncode_list_mismatch/91593376: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_list_mismatch/91593376/returncode_list_mismatch_build.sh
returncode_int_match/53aeb512: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_int_match/53aeb512
returncode_int_match/53aeb512: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_int_match/53aeb512/stage
returncode_int_match/53aeb512: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_int_match/53aeb512/returncode_int_match_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
exit1_fail/0566208b does not have any dependencies adding test to queue
returncode_list_mismatch/91593376 does not have any dependencies adding test to queue
returncode_int_match/53aeb512 does not have any dependencies adding test to queue
exit1_pass/d7846bbb does not have any dependencies adding test to queue
exit1_fail/0566208b: Running Test via command: bash --norc --noprofile -eo pipefail exit1_fail_build.sh
exit1_fail/0566208b: Test completed in 0.005727 seconds
exit1_fail/0566208b: Test completed with returncode: 1
exit1_fail/0566208b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_fail/0566208b/exit1_fail.out
exit1_fail/0566208b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_fail/0566208b/exit1_fail.err
returncode_int_match/53aeb512: Running Test via command: bash --norc --noprofile -eo pipefail returncode_int_match_build.sh
returncode_int_match/53aeb512: Test completed in 0.005336 seconds
returncode_int_match/53aeb512: Test completed with returncode: 128
returncode_int_match/53aeb512: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_int_match/53aeb512/returncode_int_match.out
returncode_int_match/53aeb512: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_int_match/53aeb512/returncode_int_match.err
returncode_int_match/53aeb512: Checking returncode - 128 is matched in list [128]
exit1_pass/d7846bbb: Running Test via command: bash --norc --noprofile -eo pipefail exit1_pass_build.sh
exit1_pass/d7846bbb: Test completed in 0.005344 seconds
exit1_pass/d7846bbb: Test completed with returncode: 1
exit1_pass/d7846bbb: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_pass/d7846bbb/exit1_pass.out
exit1_pass/d7846bbb: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/exit1_pass/d7846bbb/exit1_pass.err
exit1_pass/d7846bbb: Checking returncode - 1 is matched in list [1]
returncode_list_mismatch/91593376: Running Test via command: bash --norc --noprofile -eo pipefail returncode_list_mismatch_build.sh
returncode_list_mismatch/91593376: Test completed in 0.00547 seconds
returncode_list_mismatch/91593376: Test completed with returncode: 2
returncode_list_mismatch/91593376: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_list_mismatch/91593376/returncode_list_mismatch.out
returncode_list_mismatch/91593376: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/pass_returncode/returncode_list_mismatch/91593376/returncode_list_mismatch.err
returncode_list_mismatch/91593376: Checking returncode - 2 is matched in list [1, 3]
In this iteration we are going to run the following tests: [exit1_fail/0566208b, returncode_int_match/53aeb512, exit1_pass/d7846bbb, returncode_list_mismatch/91593376]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ returncode_i │ generic.loc… │ PASS   │ True False    │ 128        │ 0.005336 │
│ nt_match/53a │              │        │ False         │            │          │
│ eb512        │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ exit1_pass/d │ generic.loc… │ PASS   │ True False    │ 1          │ 0.005344 │
│ 7846bbb      │              │        │ False         │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ exit1_fail/0 │ generic.loc… │ FAIL   │ N/A N/A N/A   │ 1          │ 0.005727 │
│ 566208b      │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ returncode_l │ generic.loc… │ FAIL   │ False False   │ 2          │ 0.00547  │
│ ist_mismatch │              │        │ False         │            │          │
│ /91593376    │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 2/4 Percentage: 50.000%
Failed Tests: 2/4 Percentage: 50.000%


Adding 4 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_hfkt6dox.log

The returncode field can be an integer or list of integers but it may not accept duplicate values. If you specify a list of exit codes, buildtest will check actual returncode with list of expected returncodes specified by returncode field.

Shown below are examples of invalid returncodes:

# empty list is not allowed
returncode: []

# floating point is not accepted in list
returncode: [1, 1.5]

# floating point not accepted
returncode: 1.5

# duplicates are not allowed
returncode: [1, 2, 5, 5]

Passing Test based on regular expression

buildtest can configure PASS/FAIL of test based on regular expression on output or error file. This can be useful if you are expecting a certain output from the test as pose to returncode check.

In this example we introduce, the regex field which is part of status that expects a regular expression via exp. The stream property must be stdout or stderr which indicates buildtest will read output or error file and apply regular expression. If there is a match, buildtest will record the test state as PASS otherwise it will be a FAIL. In this example, we have two tests that will apply regular expression on output file.

buildspecs:
  status_regex_pass:
    executor: generic.local.bash
    type: script
    tags: [system]
    description: Pass test based on regular expression
    run: echo "PASS"
    status:
      regex:
        stream: stdout
        exp: "^(PASS)$"

  status_regex_fail:
    executor: generic.local.bash
    type: script
    tags: [system]
    description: Pass test based on regular expression
    run: echo "FAIL"
    status:
      regex:
        stream: stdout
        exp: "^(123FAIL)$"

Now if we run this test, we will see first test will pass while second one will fail even though the returncode is a 0. Take a close look at the status property

$ buildtest build -b tutorials/test_status/status_regex.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:31                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/test_status/status_regex.yml: VALID
Total builder objects created: 2
Total compiler builder: 0
Total script builder: 2
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ status_re… │ generic.l… │ None     │ None  │ None  │ Pass test  │ /home/doc… │
│            │            │          │       │       │ based on   │            │
│            │            │          │       │       │ regular    │            │
│            │            │          │       │       │ expression │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ status_re… │ generic.l… │ None     │ None  │ None  │ Pass test  │ /home/doc… │
│            │            │          │       │       │ based on   │            │
│            │            │          │       │       │ regular    │            │
│            │            │          │       │       │ expression │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
status_regex_pass/f8d5d3b1: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_pass/f8d5d3b1
status_regex_pass/f8d5d3b1: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_pass/f8d5d3b1/stage
status_regex_pass/f8d5d3b1: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_pass/f8d5d3b1/status_regex_pass_build.sh
status_regex_fail/5c147a03: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_fail/5c147a03
status_regex_fail/5c147a03: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_fail/5c147a03/stage
status_regex_fail/5c147a03: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_fail/5c147a03/status_regex_fail_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
status_regex_pass/f8d5d3b1 does not have any dependencies adding test to queue
status_regex_fail/5c147a03 does not have any dependencies adding test to queue
status_regex_pass/f8d5d3b1: Running Test via command: bash --norc --noprofile -eo pipefail status_regex_pass_build.sh
status_regex_pass/f8d5d3b1: Test completed in 0.005806 seconds
status_regex_pass/f8d5d3b1: Test completed with returncode: 0
status_regex_pass/f8d5d3b1: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_pass/f8d5d3b1/status_regex_pass.out
status_regex_pass/f8d5d3b1: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_pass/f8d5d3b1/status_regex_pass.err
status_regex_pass/f8d5d3b1: performing regular expression - '^(PASS)$' on file: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_pass/f8d5d3b1/status_regex_pass.out
status_regex_pass/f8d5d3b1: Regular Expression Match - Success!
status_regex_fail/5c147a03: Running Test via command: bash --norc --noprofile -eo pipefail status_regex_fail_build.sh
status_regex_fail/5c147a03: Test completed in 0.00536 seconds
status_regex_fail/5c147a03: Test completed with returncode: 0
status_regex_fail/5c147a03: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_fail/5c147a03/status_regex_fail.out
status_regex_fail/5c147a03: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_fail/5c147a03/status_regex_fail.err
status_regex_fail/5c147a03: performing regular expression - '^(123FAIL)$' on file: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_regex/status_regex_fail/5c147a03/status_regex_fail.out
status_regex_fail/5c147a03: Regular Expression Match - Failed!
In this iteration we are going to run the following tests: [status_regex_pass/f8d5d3b1, status_regex_fail/5c147a03]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ status_regex │ generic.loc… │ FAIL   │ False False   │ 0          │ 0.00536  │
│ _fail/5c147a │              │        │ False         │            │          │
│ 03           │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ status_regex │ generic.loc… │ PASS   │ False True    │ 0          │ 0.005806 │
│ _pass/f8d5d3 │              │        │ False         │            │          │
│ b1           │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 1/2 Percentage: 50.000%
Failed Tests: 1/2 Percentage: 50.000%


Adding 2 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_wxu50btb.log

Passing Test based on runtime

buildtest can determine state of test based on runtime property which is part of status object. This can be used if you want to control how test PASS or FAIL based on execution time of test. In example below we have five tests that make use of runtime property for passing a test. The runtime property support min and max property that can mark test pass based on minimum and maximum runtime. A test will pass if it’s execution time is greater than min time and less than max time. If min is specified without max property the upperbound is not set, likewise max without min will pass if test is less than max time. The lower bound is not set, but test runtime will be greater than 0 sec.

In test timelimit_min, we sleep for 2 seconds and it will pass because minimum runtime is 1.0 seconds. Similarly, timelimit_max will pass because we sleep for 2 seconds with a max time of 5.0.

buildspecs:
  timelimit_min_max:
    type: script
    executor: generic.local.sh
    description: "Run a sleep job for 2 seconds and test pass if its within 1.0-3.0sec"
    tags: ["tutorials"]
    run: sleep 2
    status:
      runtime:
        min: 1.0
        max: 3.0

  timelimit_min:
    type: script
    executor: generic.local.sh
    description: "Run a sleep job for 2 seconds and test pass if its exceeds min time of 1.0 sec"
    tags: ["tutorials"]
    run: sleep 2
    status:
      runtime:
        min: 1.0

  timelimit_max:
    type: script
    executor: generic.local.sh
    description: "Run a sleep job for 2 seconds and test pass if it's within max time: 5.0 sec"
    tags: ["tutorials"]
    run: sleep 2
    status:
      runtime:
        max: 5.0

  timelimit_min_fail:
    type: script
    executor: generic.local.sh
    description: "This test fails because it runs less than mintime of 10 second"
    tags: ["tutorials"]
    run: sleep 2
    status:
      runtime:
        min: 10.0

  timelimit_max_fail:
    type: script
    executor: generic.local.sh
    description: "This test fails because it exceeds maxtime of 1.0 second"
    tags: ["tutorials"]
    run: sleep 3
    status:
      runtime:
        max: 1.0
$ buildtest build -b tutorials/test_status/runtime_status_test.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:32                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/test_status/runtime_status_test.yml: VALID
Total builder objects created: 5
Total compiler builder: 0
Total script builder: 5
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ timelimit… │ generic.l… │ None     │ None  │ None  │ Run a      │ /home/doc… │
│            │            │          │       │       │ sleep job  │            │
│            │            │          │       │       │ for 2      │            │
│            │            │          │       │       │ seconds    │            │
│            │            │          │       │       │ and test   │            │
│            │            │          │       │       │ pass if    │            │
│            │            │          │       │       │ its within │            │
│            │            │          │       │       │ 1.0-3.0sec │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ timelimit… │ generic.l… │ None     │ None  │ None  │ Run a      │ /home/doc… │
│            │            │          │       │       │ sleep job  │            │
│            │            │          │       │       │ for 2      │            │
│            │            │          │       │       │ seconds    │            │
│            │            │          │       │       │ and test   │            │
│            │            │          │       │       │ pass if    │            │
│            │            │          │       │       │ its        │            │
│            │            │          │       │       │ exceeds    │            │
│            │            │          │       │       │ min time   │            │
│            │            │          │       │       │ of 1.0 sec │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ timelimit… │ generic.l… │ None     │ None  │ None  │ Run a      │ /home/doc… │
│            │            │          │       │       │ sleep job  │            │
│            │            │          │       │       │ for 2      │            │
│            │            │          │       │       │ seconds    │            │
│            │            │          │       │       │ and test   │            │
│            │            │          │       │       │ pass if    │            │
│            │            │          │       │       │ it's       │            │
│            │            │          │       │       │ within max │            │
│            │            │          │       │       │ time: 5.0  │            │
│            │            │          │       │       │ sec        │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ timelimit… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ fails      │            │
│            │            │          │       │       │ because it │            │
│            │            │          │       │       │ runs less  │            │
│            │            │          │       │       │ than       │            │
│            │            │          │       │       │ mintime of │            │
│            │            │          │       │       │ 10 second  │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ timelimit… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ fails      │            │
│            │            │          │       │       │ because it │            │
│            │            │          │       │       │ exceeds    │            │
│            │            │          │       │       │ maxtime of │            │
│            │            │          │       │       │ 1.0 second │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
timelimit_min_max/e7845be3: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_max/e7845be3
timelimit_min_max/e7845be3: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_max/e7845be3/stage
timelimit_min_max/e7845be3: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_max/e7845be3/timelimit_min_max_build.sh
timelimit_min/ec268b52: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min/ec268b52
timelimit_min/ec268b52: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min/ec268b52/stage
timelimit_min/ec268b52: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min/ec268b52/timelimit_min_build.sh
timelimit_max/e92be03e: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max/e92be03e
timelimit_max/e92be03e: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max/e92be03e/stage
timelimit_max/e92be03e: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max/e92be03e/timelimit_max_build.sh
timelimit_min_fail/b73c1570: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_fail/b73c1570
timelimit_min_fail/b73c1570: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_fail/b73c1570/stage
timelimit_min_fail/b73c1570: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_fail/b73c1570/timelimit_min_fail_build.sh
timelimit_max_fail/533ade2b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max_fail/533ade2b
timelimit_max_fail/533ade2b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max_fail/533ade2b/stage
timelimit_max_fail/533ade2b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max_fail/533ade2b/timelimit_max_fail_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
timelimit_max/e92be03e does not have any dependencies adding test to queue
timelimit_min_max/e7845be3 does not have any dependencies adding test to queue
timelimit_min/ec268b52 does not have any dependencies adding test to queue
timelimit_max_fail/533ade2b does not have any dependencies adding test to queue
timelimit_min_fail/b73c1570 does not have any dependencies adding test to queue
timelimit_max/e92be03e: Running Test via command: sh --norc --noprofile -eo pipefail timelimit_max_build.sh
timelimit_max/e92be03e: Test completed in 0.003317 seconds
timelimit_max/e92be03e: Test completed with returncode: 2
timelimit_max/e92be03e: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max/e92be03e/timelimit_max.out
timelimit_max/e92be03e: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max/e92be03e/timelimit_max.err
timelimit_min_max/e7845be3: Running Test via command: sh --norc --noprofile -eo pipefail timelimit_min_max_build.sh
timelimit_min_max/e7845be3: Test completed in 0.003124 seconds
timelimit_min_max/e7845be3: Test completed with returncode: 2
timelimit_min_max/e7845be3: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_max/e7845be3/timelimit_min_max.out
timelimit_min_max/e7845be3: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_max/e7845be3/timelimit_min_max.err
timelimit_min/ec268b52: Running Test via command: sh --norc --noprofile -eo pipefail timelimit_min_build.sh
timelimit_min/ec268b52: Test completed in 0.00293 seconds
timelimit_min/ec268b52: Test completed with returncode: 2
timelimit_min/ec268b52: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min/ec268b52/timelimit_min.out
timelimit_min/ec268b52: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min/ec268b52/timelimit_min.err
timelimit_max_fail/533ade2b: Running Test via command: sh --norc --noprofile -eo pipefail timelimit_max_fail_build.sh
timelimit_max_fail/533ade2b: Test completed in 0.003014 seconds
timelimit_max_fail/533ade2b: Test completed with returncode: 2
timelimit_max_fail/533ade2b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max_fail/533ade2b/timelimit_max_fail.out
timelimit_max_fail/533ade2b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_max_fail/533ade2b/timelimit_max_fail.err
timelimit_min_fail/b73c1570: Running Test via command: sh --norc --noprofile -eo pipefail timelimit_min_fail_build.sh
timelimit_min_fail/b73c1570: Test completed in 0.003153 seconds
timelimit_min_fail/b73c1570: Test completed with returncode: 2
timelimit_min_fail/b73c1570: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_fail/b73c1570/timelimit_min_fail.out
timelimit_min_fail/b73c1570: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/runtime_status_test/timelimit_min_fail/b73c1570/timelimit_min_fail.err
In this iteration we are going to run the following tests: [timelimit_max/e92be03e, timelimit_min_max/e7845be3, timelimit_min/ec268b52, timelimit_max_fail/533ade2b, timelimit_min_fail/b73c1570]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ timelimit_mi │ generic.loc… │ FAIL   │ False False   │ 2          │ 0.003124 │
│ n_max/e7845b │              │        │ False         │            │          │
│ e3           │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ timelimit_mi │ generic.loc… │ FAIL   │ False False   │ 2          │ 0.003153 │
│ n_fail/b73c1 │              │        │ False         │            │          │
│ 570          │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ timelimit_ma │ generic.loc… │ PASS   │ False False   │ 2          │ 0.003317 │
│ x/e92be03e   │              │        │ True          │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ timelimit_ma │ generic.loc… │ PASS   │ False False   │ 2          │ 0.003014 │
│ x_fail/533ad │              │        │ True          │            │          │
│ e2b          │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ timelimit_mi │ generic.loc… │ FAIL   │ False False   │ 2          │ 0.00293  │
│ n/ec268b52   │              │        │ False         │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 2/5 Percentage: 40.000%
Failed Tests: 3/5 Percentage: 60.000%


Adding 5 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_ujlgeik9.log

If we look at the test results, we expect the first three tests timelimit_min, timelimit_max, timelimit_min_max will pass while the last two tests fail because it fails to comply with runtime property.

$ buildtest report --filter buildspec=tutorials/test_status/runtime_status_test.yml --format name,id,state,runtime --latest
Report File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ name                           ┃ id             ┃ state      ┃ runtime       ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ timelimit_min_max              │ e7845be3       │ FAIL       │ 0.003124      │
├────────────────────────────────┼────────────────┼────────────┼───────────────┤
│ timelimit_min_fail             │ b73c1570       │ FAIL       │ 0.003153      │
├────────────────────────────────┼────────────────┼────────────┼───────────────┤
│ timelimit_max                  │ e92be03e       │ PASS       │ 0.003317      │
├────────────────────────────────┼────────────────┼────────────┼───────────────┤
│ timelimit_max_fail             │ 533ade2b       │ PASS       │ 0.003014      │
├────────────────────────────────┼────────────────┼────────────┼───────────────┤
│ timelimit_min                  │ ec268b52       │ FAIL       │ 0.00293       │
└────────────────────────────────┴────────────────┴────────────┴───────────────┘

Explicitly Declaring Status of Test

You can explicitly define status of test regardless of what buildtest does for checking status of test. This can be useful if you want to explicitly mark a test as PASS or FAIL regardless of how test behaves. This can be done via state property which expects one of two types PASS or FAIL. If state property is specified, buildtest will ignore any checks including returncode, regex, or runtime match.

In this next example we will demonstrate how one can use state property for marking test state. In this example we have four tests. The first test always_pass will PASS even though we have a non-zero returncode. The second test always_fail will FAIL even though it has a 0 returncode. The last two test demonstrate how one can define state regardless of what is specified for returncode match. buildtest will honor the state property even if their is a match on the returncode.

buildspecs:
  always_pass:
    type: script
    executor: 'generic.local.sh'
    description: This test will always 'PASS'
    run: exit 1
    status:
      state: PASS

  always_fail:
    type: script
    executor: 'generic.local.sh'
    description: This test will always 'FAIL'
    run: exit 0
    status:
      state: FAIL

  test_fail_returncode_match:
    type: script
    executor: 'generic.local.sh'
    description: This test will 'FAIL' even if we have returncode match
    run: exit 1
    status:
      state: FAIL
      returncode: 1

  test_pass_returncode_mismatch:
    type: script
    executor: 'generic.local.sh'
    description: This test will 'PASS' even if we have returncode mismatch
    run: exit 1
    status:
      state: PASS
      returncode: 2

If we build this test, we expect buildtest to honor the value of state property

$ buildtest build -b tutorials/test_status/explicit_state.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:33                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/test_status/explicit_state.yml: VALID
Total builder objects created: 4
Total compiler builder: 0
Total script builder: 4
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ always_pa… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will       │            │
│            │            │          │       │       │ always     │            │
│            │            │          │       │       │ 'PASS'     │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ always_fa… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will       │            │
│            │            │          │       │       │ always     │            │
│            │            │          │       │       │ 'FAIL'     │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ test_fail… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will       │            │
│            │            │          │       │       │ 'FAIL'     │            │
│            │            │          │       │       │ even if we │            │
│            │            │          │       │       │ have       │            │
│            │            │          │       │       │ returncode │            │
│            │            │          │       │       │ match      │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ test_pass… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will       │            │
│            │            │          │       │       │ 'PASS'     │            │
│            │            │          │       │       │ even if we │            │
│            │            │          │       │       │ have       │            │
│            │            │          │       │       │ returncode │            │
│            │            │          │       │       │ mismatch   │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
always_pass/d1de434e: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_pass/d1de434e
always_pass/d1de434e: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_pass/d1de434e/stage
always_pass/d1de434e: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_pass/d1de434e/always_pass_build.sh
always_fail/2c2d296c: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_fail/2c2d296c
always_fail/2c2d296c: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_fail/2c2d296c/stage
always_fail/2c2d296c: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_fail/2c2d296c/always_fail_build.sh
test_fail_returncode_match/fe6f1d2b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_fail_returncode_match/fe6f1d2b
test_fail_returncode_match/fe6f1d2b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_fail_returncode_match/fe6f1d2b/stage
test_fail_returncode_match/fe6f1d2b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_fail_returncode_match/fe6f1d2b/test_fail_returncode_match_build.sh
test_pass_returncode_mismatch/e826910b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_pass_returncode_mismatch/e826910b
test_pass_returncode_mismatch/e826910b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_pass_returncode_mismatch/e826910b/stage
test_pass_returncode_mismatch/e826910b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_pass_returncode_mismatch/e826910b/test_pass_returncode_mismatch_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
always_pass/d1de434e does not have any dependencies adding test to queue
test_fail_returncode_match/fe6f1d2b does not have any dependencies adding test to queue
always_fail/2c2d296c does not have any dependencies adding test to queue
test_pass_returncode_mismatch/e826910b does not have any dependencies adding test to queue
always_pass/d1de434e: Running Test via command: sh --norc --noprofile -eo pipefail always_pass_build.sh
always_pass/d1de434e: Test completed in 0.003106 seconds
always_pass/d1de434e: Test completed with returncode: 2
always_pass/d1de434e: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_pass/d1de434e/always_pass.out
always_pass/d1de434e: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_pass/d1de434e/always_pass.err
always_fail/2c2d296c: Running Test via command: sh --norc --noprofile -eo pipefail always_fail_build.sh
always_fail/2c2d296c: Test completed in 0.0032 seconds
always_fail/2c2d296c: Test completed with returncode: 2
always_fail/2c2d296c: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_fail/2c2d296c/always_fail.out
always_fail/2c2d296c: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/always_fail/2c2d296c/always_fail.err
test_fail_returncode_match/fe6f1d2b: Running Test via command: sh --norc --noprofile -eo pipefail test_fail_returncode_match_build.sh
test_fail_returncode_match/fe6f1d2b: Test completed in 0.003075 seconds
test_fail_returncode_match/fe6f1d2b: Test completed with returncode: 2
test_fail_returncode_match/fe6f1d2b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_fail_returncode_match/fe6f1d2b/test_fail_returncode_match.out
test_fail_returncode_match/fe6f1d2b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_fail_returncode_match/fe6f1d2b/test_fail_returncode_match.err
test_fail_returncode_match/fe6f1d2b: Checking returncode - 2 is matched in list [1]
test_pass_returncode_mismatch/e826910b: Running Test via command: sh --norc --noprofile -eo pipefail test_pass_returncode_mismatch_build.sh
test_pass_returncode_mismatch/e826910b: Test completed in 0.00296 seconds
test_pass_returncode_mismatch/e826910b: Test completed with returncode: 2
test_pass_returncode_mismatch/e826910b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_pass_returncode_mismatch/e826910b/test_pass_returncode_mismatch.out
test_pass_returncode_mismatch/e826910b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/explicit_state/test_pass_returncode_mismatch/e826910b/test_pass_returncode_mismatch.err
test_pass_returncode_mismatch/e826910b: Checking returncode - 2 is matched in list [2]
In this iteration we are going to run the following tests: [always_pass/d1de434e, always_fail/2c2d296c, test_fail_returncode_match/fe6f1d2b, test_pass_returncode_mismatch/e826910b]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ always_fail/ │ generic.loc… │ FAIL   │ False False   │ 2          │ 0.0032   │
│ 2c2d296c     │              │        │ False         │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ test_pass_re │ generic.loc… │ PASS   │ True False    │ 2          │ 0.00296  │
│ turncode_mis │              │        │ False         │            │          │
│ match/e82691 │              │        │               │            │          │
│ 0b           │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ always_pass/ │ generic.loc… │ PASS   │ False False   │ 2          │ 0.003106 │
│ d1de434e     │              │        │ False         │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ test_fail_re │ generic.loc… │ FAIL   │ False False   │ 2          │ 0.003075 │
│ turncode_mat │              │        │ False         │            │          │
│ ch/fe6f1d2b  │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 2/4 Percentage: 50.000%
Failed Tests: 2/4 Percentage: 50.000%


Adding 4 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_rospnihw.log

Defining Tags

The tags field can be used to classify tests which can be used to organize tests or if you want to Building By Tags (buildtest build --tags <TAGNAME>). Tags can be defined as a string or list of strings. In this example, the test string_tag defines a tag name network while test list_of_strings_tags define a list of tags named network and ping.

buildspecs:
  string_tag:
    type: script
    executor: generic.local.bash
    description: tags can be a string
    tags: network
    run: hostname

  list_of_strings_tags:
    type: script
    executor: generic.local.bash
    description: tags can be a list of strings
    tags: [network, ping]
    run: ping -c 4 www.google.com

Each item in tags must be a string and no duplicates are allowed, for example in this test, we define a duplicate tag network which is not allowed.

buildspecs:
  duplicate_string_tags:
    type: script
    executor: generic.local.bash
    description: duplicate strings in tags list is not allowed
    tags: [network, network]
    run: hostname

If we run this test and inspect the logs we will see an error message in schema validation:

2020-09-29 10:56:43,175 [parser.py:179 - _validate() ] - [INFO] Validating test - 'duplicate_string_tags' with schemafile: script-v1.0.schema.json
2020-09-29 10:56:43,175 [buildspec.py:397 - parse_buildspecs() ] - [ERROR] ['network', 'network'] is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['tags']:
    {'oneOf': [{'type': 'string'},
               {'$ref': '#/definitions/list_of_strings'}]}

On instance['tags']:
    ['network', 'network']

If tags is a list, it must contain one item, therefore an empty list (i.e tags: []) is invalid.

Customize Shell

Shell Type

buildtest will default to bash shell when running test, but we can configure shell option using the shell field. The shell field is defined in schema as follows:

"shell": {
  "type": "string",
  "description": "Specify a shell launcher to use when running jobs. This sets the shebang line in your test script. The ``shell`` key can be used with ``run`` section to describe content of script and how its executed",
  "pattern": "^(/bin/bash|/bin/sh|/bin/csh|/bin/tcsh|/bin/zsh|bash|sh|csh|tcsh|zsh|python).*"
},

The shell pattern is a regular expression where one can specify a shell name along with shell options. The shell will configure the shebang in the test-script. In this example, we illustrate a few tests using different shell field.

buildspecs:
  _bin_sh_shell:
    executor: generic.local.sh
    type: script
    description: "/bin/sh shell example"
    shell: /bin/sh
    tags: [tutorials]
    run: "bzip2 --help"

  _bin_bash_shell:
    executor: generic.local.bash
    type: script
    description: "/bin/bash shell example"
    shell: /bin/bash
    tags: [tutorials]
    run: "bzip2 -h"

  bash_shell:
    executor: generic.local.bash
    type: script
    description: "bash shell example"
    shell: bash
    tags: [tutorials]
    run: "echo $SHELL"

  sh_shell:
    executor: generic.local.sh
    type: script
    description: "sh shell example"
    shell: sh
    tags: [tutorials]
    run: "echo $SHELL"

  shell_options:
    executor: generic.local.sh
    type: script
    description: "shell options"
    shell: "sh -x"
    tags: [tutorials]
    run: |
      echo $SHELL
      hostname

The generated test-script for buildspec _bin_sh_shell will specify shebang /bin/sh because we specified shell: /bin/sh:

#!/bin/sh
# Content of run section
bzip2 --help

If you don’t specify a shell path such as shell: sh, then buildtest will resolve path by looking in $PATH and build the shebang line.

In test shell_options we specify shell: "sh -x", buildtest will tack on the shell options into the called script as follows:

#!/bin/bash


############# START VARIABLE DECLARATION ########################
export BUILDTEST_TEST_NAME=shell_options
export BUILDTEST_TEST_ROOT=/Users/siddiq90/Documents/GitHubDesktop/buildtest/var/tests/generic.local.sh/shell_examples/shell_options/0
export BUILDTEST_BUILDSPEC_DIR=/Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials
export BUILDTEST_STAGE_DIR=/Users/siddiq90/Documents/GitHubDesktop/buildtest/var/tests/generic.local.sh/shell_examples/shell_options/0/stage
export BUILDTEST_TEST_ID=95c11f54-bbb1-4154-849d-44313e4417c2
############# END VARIABLE DECLARATION   ########################


# source executor startup script
source /Users/siddiq90/Documents/GitHubDesktop/buildtest/var/executor/generic.local.sh/before_script.sh
# Run generated script
sh -x /Users/siddiq90/Documents/GitHubDesktop/buildtest/var/tests/generic.local.sh/shell_examples/shell_options/0/stage/shell_options.sh
# Get return code
returncode=$?
# Exit with return code
exit $returncode

If you prefer csh or tcsh for writing scripts just set shell: csh or shell: tcsh, note you will need to match this with appropriate executor. For now use executor: generic.local.csh to run your csh/tcsh scripts. In this example below we define a script using csh, take note of run section we can write csh style.

buildspecs:
  csh_shell:
    executor: generic.local.csh
    type: script
    description: "csh shell example"
    shell: csh
    tags: [tutorials]
    vars:
      file: "/etc/csh.cshrc"
    run: |
      if (-e $file) then
        echo "$file file found"
      else
        echo "$file file not found"
        exit 1
      endif

Customize Shebang

You may customize the shebang line in testscript using shebang field. This takes precedence over the shell property which automatically detects the shebang based on shell path.

In next example we have two tests bash_login_shebang and bash_nonlogin_shebang which tests if shell is Login or Non-Login. The #!/bin/bash -l indicates we want to run in login shell and expects an output of Login Shell while test bash_nonlogin_shebang should run in default behavior which is non-login shell and expects output Not Login Shell. We match this with regular expression with stdout stream.

buildspecs:
  bash_login_shebang:
    type: script
    executor: generic.local.bash
    shebang: "#!/bin/bash -l"
    description: customize shebang line with bash login shell
    tags: tutorials
    run: shopt -q login_shell && echo 'Login Shell' || echo 'Not Login Shell'
    status:
      regex:
        exp: "^Login Shell$"
        stream: stdout

  bash_nonlogin_shebang:
    type: script
    executor: generic.local.bash
    shebang: "#!/bin/bash"
    description: customize shebang line with default bash (nonlogin) shell
    tags: tutorials
    run: shopt -q login_shell && echo 'Login Shell' || echo 'Not Login Shell'
    status:
      regex:
        exp: "^Not Login Shell$"
        stream: stdout

Now let’s run this test as we see the following.

$ buildtest build -b tutorials/shebang.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:34                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/shebang.yml: VALID
Total builder objects created: 2
Total compiler builder: 0
Total script builder: 2
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ bash_logi… │ generic.l… │ None     │ None  │ None  │ customize  │ /home/doc… │
│            │            │          │       │       │ shebang    │            │
│            │            │          │       │       │ line with  │            │
│            │            │          │       │       │ bash login │            │
│            │            │          │       │       │ shell      │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ bash_nonl… │ generic.l… │ None     │ None  │ None  │ customize  │ /home/doc… │
│            │            │          │       │       │ shebang    │            │
│            │            │          │       │       │ line with  │            │
│            │            │          │       │       │ default    │            │
│            │            │          │       │       │ bash       │            │
│            │            │          │       │       │ (nonlogin) │            │
│            │            │          │       │       │ shell      │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
bash_login_shebang/825d248b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_login_shebang/825d248b
bash_login_shebang/825d248b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_login_shebang/825d248b/stage
bash_login_shebang/825d248b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_login_shebang/825d248b/bash_login_shebang_build.sh
bash_nonlogin_shebang/83cefab1: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_nonlogin_shebang/83cefab1
bash_nonlogin_shebang/83cefab1: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_nonlogin_shebang/83cefab1/stage
bash_nonlogin_shebang/83cefab1: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_nonlogin_shebang/83cefab1/bash_nonlogin_shebang_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
bash_login_shebang/825d248b does not have any dependencies adding test to queue
bash_nonlogin_shebang/83cefab1 does not have any dependencies adding test to queue
bash_login_shebang/825d248b: Running Test via command: bash --norc --noprofile -eo pipefail bash_login_shebang_build.sh
bash_login_shebang/825d248b: Test completed in 0.010368 seconds
bash_login_shebang/825d248b: Test completed with returncode: 0
bash_login_shebang/825d248b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_login_shebang/825d248b/bash_login_shebang.out
bash_login_shebang/825d248b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_login_shebang/825d248b/bash_login_shebang.err
bash_login_shebang/825d248b: performing regular expression - '^Login Shell$' on file: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_login_shebang/825d248b/bash_login_shebang.out
bash_login_shebang/825d248b: Regular Expression Match - Success!
bash_nonlogin_shebang/83cefab1: Running Test via command: bash --norc --noprofile -eo pipefail bash_nonlogin_shebang_build.sh
bash_nonlogin_shebang/83cefab1: Test completed in 0.005426 seconds
bash_nonlogin_shebang/83cefab1: Test completed with returncode: 0
bash_nonlogin_shebang/83cefab1: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_nonlogin_shebang/83cefab1/bash_nonlogin_shebang.out
bash_nonlogin_shebang/83cefab1: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_nonlogin_shebang/83cefab1/bash_nonlogin_shebang.err
bash_nonlogin_shebang/83cefab1: performing regular expression - '^Not Login Shell$' on file: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/shebang/bash_nonlogin_shebang/83cefab1/bash_nonlogin_shebang.out
bash_nonlogin_shebang/83cefab1: Regular Expression Match - Success!
In this iteration we are going to run the following tests: [bash_login_shebang/825d248b, bash_nonlogin_shebang/83cefab1]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ bash_nonlogi │ generic.loc… │ PASS   │ False True    │ 0          │ 0.005426 │
│ n_shebang/83 │              │        │ False         │            │          │
│ cefab1       │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ bash_login_s │ generic.loc… │ PASS   │ False True    │ 0          │ 0.010368 │
│ hebang/825d2 │              │        │ False         │            │          │
│ 48b          │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 2/2 Percentage: 100.000%
Failed Tests: 0/2 Percentage: 0.000%


Adding 2 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_i9gm61u3.log

If we look at the generated test for bash_login_shebang we see the shebang line is passed into the script:

#!/bin/bash -l
# Content of run section
shopt -q login_shell && echo 'Login Shell' || echo 'Not Login Shell'

Python Shell

You can use script schema to write python scripts using the run property. In order to write python code you must set shell property to python interpreter such as `shell: python or full path to python wrapper such as shell: /usr/bin/python.

Here is a python example calculating area of circle

buildspecs:
  circle_area:
    executor: generic.local.bash
    type: script
    shell: python
    description: "Calculate circle of area given a radius"
    tags: [tutorials, python]
    run: |
      import math
      radius = 2
      area = math.pi * radius * radius
      print("Circle Radius ", radius)
      print("Area of circle ", area)

Note

Python scripts are very picky when it comes to formatting, in the run section if you are defining multiline python script you must remember to use 2 space indent to register multiline string. buildtest will extract the content from run section and inject in your test script. To ensure proper formatting for a more complex python script you may be better off writing a python script in separate file and invoke the python script in the run section.

Skipping test

By default, buildtest will run all tests defined in buildspecs section, if you want to skip a test use the skip field which expects a boolean value. Shown below is an example test.

buildspecs:
  skip:
    type: script
    executor: generic.local.bash
    description: This test is skipped
    skip: Yes
    tags: [tutorials]
    run: hostname

  unskipped:
    type: script
    executor: generic.local.bash
    description: This test is not skipped
    skip: No
    tags: [tutorials]
    run: hostname

The first test skip will be ignored by buildtest because skip: true is defined while unskipped will be processed as usual.

Note

YAML and JSON have different representation for boolean. For json schema valid values are true and false see https://json-schema.org/understanding-json-schema/reference/boolean.html however YAML has many more representation for boolean see https://yaml.org/type/bool.html. You may use any of the YAML boolean, however it’s best to stick with json schema values true and false.

Here is an example build, notice message [skip] test is skipped during the build stage

$ buildtest build -b tutorials/skip_tests.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:34                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
skip: skipping test due to 'skip' property.
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/skip_tests.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 1
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ unskipped… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ is not     │            │
│            │            │          │       │       │ skipped    │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
unskipped/9d2baf5b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/skip_tests/unskipped/9d2baf5b
unskipped/9d2baf5b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/skip_tests/unskipped/9d2baf5b/stage
unskipped/9d2baf5b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/skip_tests/unskipped/9d2baf5b/unskipped_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
unskipped/9d2baf5b does not have any dependencies adding test to queue
unskipped/9d2baf5b: Running Test via command: bash --norc --noprofile -eo pipefail unskipped_build.sh
unskipped/9d2baf5b: Test completed in 0.006389 seconds
unskipped/9d2baf5b: Test completed with returncode: 0
unskipped/9d2baf5b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/skip_tests/unskipped/9d2baf5b/unskipped.out
unskipped/9d2baf5b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/skip_tests/unskipped/9d2baf5b/unskipped.err
In this iteration we are going to run the following tests: [unskipped/9d2baf5b]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ unskipped/9d │ generic.loc… │ PASS   │ N/A N/A N/A   │ 0          │ 0.006389 │
│ 2baf5b       │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%


Adding 1 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_lal6cxjr.log

Defining Metrics

buildtest provides a method to define test metrics in the buildspecs which can be used to store arbitrary content from the output/error file into named metric. A metric is defined using the metrics property where each element under the metrics property is the name of the metric which must be a unique name. A metric can apply regular expression on stdout, stderr like in this example below. The metrics are captured in the test report which can be queried via buildtest report or buildtest inspect. Shown below is an example where we define two metrics named hpcg_rating and hpcg_state.

buildspecs:
  metric_regex_example:
    executor: generic.local.sh
    type: script
    description: capture result metric from output
    run: echo "HPCG result is VALID with a GFLOP/s rating of=63.6515"
    tags: tutorials
    metrics:
      hpcg_rating:
        regex:
          exp: '(\d+\.\d+)$'
          stream: stdout

      hpcg_state:
        regex:
          exp: '(VALID)'
          stream: stdout

The metrics will not impact behavior of test, it will only impact the test report. By default a metric will be an empty dictionary if there is no metrics property. If we fail to match a regular expression, the metric will be defined as an empty string.

Note

If your regular expression contains an escape character \ you must surround your string in single quotes ' as pose to double quotes "

Let’s build this test.

$ buildtest build -b tutorials/metrics_regex.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:35                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/metrics_regex.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 1
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ metric_re… │ generic.l… │ None     │ None  │ None  │ capture    │ /home/doc… │
│            │            │          │       │       │ result     │            │
│            │            │          │       │       │ metric     │            │
│            │            │          │       │       │ from       │            │
│            │            │          │       │       │ output     │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
metric_regex_example/dddffd59: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/metrics_regex/metric_regex_example/dddffd59
metric_regex_example/dddffd59: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/metrics_regex/metric_regex_example/dddffd59/stage
metric_regex_example/dddffd59: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/metrics_regex/metric_regex_example/dddffd59/metric_regex_example_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
metric_regex_example/dddffd59 does not have any dependencies adding test to queue
metric_regex_example/dddffd59: Running Test via command: sh --norc --noprofile -eo pipefail metric_regex_example_build.sh
metric_regex_example/dddffd59: Test completed in 0.003343 seconds
metric_regex_example/dddffd59: Test completed with returncode: 2
metric_regex_example/dddffd59: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/metrics_regex/metric_regex_example/dddffd59/metric_regex_example.out
metric_regex_example/dddffd59: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/metrics_regex/metric_regex_example/dddffd59/metric_regex_example.err
In this iteration we are going to run the following tests: [metric_regex_example/dddffd59]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ metric_regex │ generic.loc… │ FAIL   │ N/A N/A N/A   │ 2          │ 0.003343 │
│ _example/ddd │              │        │               │            │          │
│ ffd59        │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 0/1 Percentage: 0.000%
Failed Tests: 1/1 Percentage: 100.000%


Adding 1 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_dyn9pxsd.log

We can query the metrics via buildtest report which will display all metrics as a comma separted Key/Value pair. We can use buildtest report --format metrics to extract all metrics for a test. Internally, we store the metrics as a dictionary but when we print them out via buildtest report we join them together into a single string. Shown below is the metrics for the previous build.

$ buildtest report --filter buildspec=tutorials/metrics_regex.yml --format name,metrics
Report File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ name                               ┃ metrics                                 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ metric_regex_example               │ hpcg_rating=,hpcg_state=                │
└────────────────────────────────────┴─────────────────────────────────────────┘

You can define a metric based on variables or environment variables which requires you have set vars or env property in the buildspec. The vars and env is a property under the metric name that can be used to reference name of variable or environment variable. If you reference an invalid name, buildtest will assign the metric an empty string. In this next example, we define two metrics gflop and foo that are assigned to variable GFLOPS and environment variable FOO.

Test Dependency

Note

This feature is subject to change

Buildtest can support test dependencies which allows one to specify condition before running a test. Let’s take a look at this next example, we have a buildspec with three tests jobA, jobB, and jobC. The test jobA will run immediately but now we introduce a new keyword needs which is a list of test names as dependency. We want test jobB to run after jobA is complete, and jobC to run once jobA and jobB is complete.

buildspecs:
  jobA:
    type: script
    executor: generic.local.bash
    description: no job dependency
    run: |
      echo "This job has no dependency"
      sleep 5

  jobB:
    type: script
    executor: generic.local.bash
    description: job dependency on jobA
    needs: [jobA]
    run: |
      echo "This job depends on jobA"
      sleep 2

  jobC:
    type: script
    executor: generic.local.bash
    description: job dependency on jobA and jobB
    needs: [jobA, jobB]
    run: |
      echo "This job depends on jobA and jobB"
      sleep 2

The needs property expects a list of strings, and values must match name of test. If you specify an invalid test name in needs property then buildtest will ignore the value. If multiple tests are specified in needs property then all test must finish prior to running test.

Let’s run this test, and take a note that buildtest will run test jobA, followed by jobB then jobC.

$ buildtest build -b tutorials/job_dependency/ex1.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:36                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/job_dependency/ex1.yml: VALID
Total builder objects created: 3
Total compiler builder: 0
Total script builder: 3
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ jobA/195f… │ generic.l… │ None     │ None  │ None  │ no job     │ /home/doc… │
│            │            │          │       │       │ dependency │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ jobB/1026… │ generic.l… │ None     │ None  │ None  │ job        │ /home/doc… │
│            │            │          │       │       │ dependency │            │
│            │            │          │       │       │ on jobA    │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ jobC/305e… │ generic.l… │ None     │ None  │ None  │ job        │ /home/doc… │
│            │            │          │       │       │ dependency │            │
│            │            │          │       │       │ on jobA    │            │
│            │            │          │       │       │ and jobB   │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
jobA/195f85ae: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobA/195f85ae
jobA/195f85ae: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobA/195f85ae/stage
jobA/195f85ae: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobA/195f85ae/jobA_build.sh
jobB/10265887: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobB/10265887
jobB/10265887: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobB/10265887/stage
jobB/10265887: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobB/10265887/jobB_build.sh
jobC/305eca2f: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobC/305eca2f
jobC/305eca2f: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobC/305eca2f/stage
jobC/305eca2f: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobC/305eca2f/jobC_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
jobB/10265887 Skipping job because it has job dependency on jobA/195f85ae which is in state PENDING
jobA/195f85ae does not have any dependencies adding test to queue
jobC/305eca2f Skipping job because it has job dependency on jobA/195f85ae which is in state PENDING
jobA/195f85ae: Running Test via command: bash --norc --noprofile -eo pipefail jobA_build.sh
jobA/195f85ae: Test completed in 5.00717 seconds
jobA/195f85ae: Test completed with returncode: 0
jobA/195f85ae: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobA/195f85ae/jobA.out
jobA/195f85ae: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobA/195f85ae/jobA.err
In this iteration we are going to run the following tests: [jobA/195f85ae]
───────────────────────────────── Iteration 2 ──────────────────────────────────
jobC/305eca2f Skipping job because it has job dependency on jobB/10265887 which is in state PENDING
jobB/10265887: Running Test via command: bash --norc --noprofile -eo pipefail jobB_build.sh
jobB/10265887: Test completed in 2.007138 seconds
jobB/10265887: Test completed with returncode: 0
jobB/10265887: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobB/10265887/jobB.out
jobB/10265887: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobB/10265887/jobB.err
In this iteration we are going to run the following tests: [jobB/10265887]
───────────────────────────────── Iteration 3 ──────────────────────────────────
jobC/305eca2f: Running Test via command: bash --norc --noprofile -eo pipefail jobC_build.sh
jobC/305eca2f: Test completed in 2.007927 seconds
jobC/305eca2f: Test completed with returncode: 0
jobC/305eca2f: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobC/305eca2f/jobC.out
jobC/305eca2f: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex1/jobC/305eca2f/jobC.err
In this iteration we are going to run the following tests: [jobC/305eca2f]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃               ┃        ┃ checks       ┃            ┃          ┃
┃              ┃               ┃        ┃ (ReturnCode, ┃            ┃          ┃
┃              ┃               ┃        ┃ Regex,       ┃            ┃          ┃
┃ builder      ┃ executor      ┃ status ┃ Runtime)     ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ jobA/195f85a │ generic.loca… │ PASS   │ N/A N/A N/A  │ 0          │ 5.00717  │
│ e            │               │        │              │            │          │
├──────────────┼───────────────┼────────┼──────────────┼────────────┼──────────┤
│ jobB/1026588 │ generic.loca… │ PASS   │ N/A N/A N/A  │ 0          │ 2.007138 │
│ 7            │               │        │              │            │          │
├──────────────┼───────────────┼────────┼──────────────┼────────────┼──────────┤
│ jobC/305eca2 │ generic.loca… │ PASS   │ N/A N/A N/A  │ 0          │ 2.007927 │
│ f            │               │        │              │            │          │
└──────────────┴───────────────┴────────┴──────────────┴────────────┴──────────┘



Passed Tests: 3/3 Percentage: 100.000%
Failed Tests: 0/3 Percentage: 0.000%


Adding 3 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_fnw6932i.log

Test Dependency by returncode

In this next example, we can control behavior of job dependency based on returncode for a given test. This test has three tests: test1, test2 and test3. The first test will exit with returncode 1 but this test will pass because we have set state: PASS to override the status check. The next test test2 requires test1 to have a returncode of 1 in order to satisfy dependency. The returncode property expects a valid returncode and it can be a list of returncode similar to how one specify returncode under the status property see Return Code Matching. The needs property can support multiple test with returncode, in test3 we require test1 to have returncode 1 while test2 has a returncode of 2. We expect test2 to return a returncode of 2 because of exit 2 statement so we expect all three tests to run.

buildspecs:
  test1:
    type: script
    executor: generic.local.bash
    description: This test will pass with exit 1
    run: exit 1
    status:
      state: PASS

  test2:
    type: script
    executor: generic.local.bash
    description: This test will run if test1 has returncode 1
    run: exit 2
    status:
      state: PASS
    needs:
      - test1:
          returncode: 1

  test3:
    type: script
    executor: generic.local.bash
    description: This test will run if test1 has returncode 1 and test2 has returncode 2
    run: exit 1
    status:
      state: PASS
    needs:
      - test1:
          returncode: 1
      - test2:
          returncode: 2

Let’s build this test and take note of execution order of test.

$ buildtest build -b tutorials/job_dependency/ex2.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:46                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/job_dependency/ex2.yml: VALID
Total builder objects created: 3
Total compiler builder: 0
Total script builder: 3
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ test1/d36… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will pass  │            │
│            │            │          │       │       │ with exit  │            │
│            │            │          │       │       │ 1          │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ test2/3a1… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will run   │            │
│            │            │          │       │       │ if test1   │            │
│            │            │          │       │       │ has        │            │
│            │            │          │       │       │ returncode │            │
│            │            │          │       │       │ 1          │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ test3/514… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will run   │            │
│            │            │          │       │       │ if test1   │            │
│            │            │          │       │       │ has        │            │
│            │            │          │       │       │ returncode │            │
│            │            │          │       │       │ 1 and      │            │
│            │            │          │       │       │ test2 has  │            │
│            │            │          │       │       │ returncode │            │
│            │            │          │       │       │ 2          │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
test1/d367a48d: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test1/d367a48d
test1/d367a48d: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test1/d367a48d/stage
test1/d367a48d: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test1/d367a48d/test1_build.sh
test2/3a1fd28f: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test2/3a1fd28f
test2/3a1fd28f: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test2/3a1fd28f/stage
test2/3a1fd28f: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test2/3a1fd28f/test2_build.sh
test3/514936b9: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test3/514936b9
test3/514936b9: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test3/514936b9/stage
test3/514936b9: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test3/514936b9/test3_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
test2/3a1fd28f Skipping job because it has job dependency on test1/d367a48d 
test3/514936b9 Skipping job because it has job dependency on test1/d367a48d 
test1/d367a48d does not have any dependencies adding test to queue
test1/d367a48d: Running Test via command: bash --norc --noprofile -eo pipefail test1_build.sh
test1/d367a48d: Test completed in 0.005447 seconds
test1/d367a48d: Test completed with returncode: 1
test1/d367a48d: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test1/d367a48d/test1.out
test1/d367a48d: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test1/d367a48d/test1.err
In this iteration we are going to run the following tests: [test1/d367a48d]
───────────────────────────────── Iteration 2 ──────────────────────────────────
test3/514936b9 Skipping job because it has job dependency on test2/3a1fd28f 
test2/3a1fd28f: Running Test via command: bash --norc --noprofile -eo pipefail test2_build.sh
test2/3a1fd28f: Test completed in 0.005151 seconds
test2/3a1fd28f: Test completed with returncode: 2
test2/3a1fd28f: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test2/3a1fd28f/test2.out
test2/3a1fd28f: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test2/3a1fd28f/test2.err
In this iteration we are going to run the following tests: [test2/3a1fd28f]
───────────────────────────────── Iteration 3 ──────────────────────────────────
test3/514936b9: Running Test via command: bash --norc --noprofile -eo pipefail test3_build.sh
test3/514936b9: Test completed in 0.005094 seconds
test3/514936b9: Test completed with returncode: 1
test3/514936b9: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test3/514936b9/test3.out
test3/514936b9: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex2/test3/514936b9/test3.err
In this iteration we are going to run the following tests: [test3/514936b9]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ test1/d367a4 │ generic.loc… │ PASS   │ False False   │ 1          │ 0.005447 │
│ 8d           │              │        │ False         │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ test3/514936 │ generic.loc… │ PASS   │ False False   │ 1          │ 0.005094 │
│ b9           │              │        │ False         │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ test2/3a1fd2 │ generic.loc… │ PASS   │ False False   │ 2          │ 0.005151 │
│ 8f           │              │        │ False         │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 3/3 Percentage: 100.000%
Failed Tests: 0/3 Percentage: 0.000%


Adding 3 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_tsus4s1c.log

Test Dependency by state

You can specify state as a property to check for test state when specify test dependency. In this next example, we have have four tests pass_test, fail_test, pass_and_fail_test, and final_test. The first test will be a PASS because we have state: PASS. The test fail_test depends on pass_test only if it has state: PASS, if value is mismatch then test will be skipped. Note that buildtest will skip test until next iteration if test is not executed, however if test is complete then buildtest will cancel dependent test. We can specify multiple test dependencies with state property such as test pass_and_fail_test which expects pass_test to have state: PASS and fail_test to have state: FAIL. In test final_test, shows how you can combine the format, the needs property is a list of object where each element is name of test. If no properties are associated with test name then buildtest will wait until job is complete to execute test. In this example, the test expects both pass_test and fail_test to run while pass_and_fail_test must have returncode of 1.

buildspecs:
  pass_test:
    type: script
    executor: generic.local.bash
    description: This test will always pass
    status:
      state: PASS
    run: |
      echo "This test will pass"
      sleep 2

  fail_test:
    type: script
    executor: generic.local.bash
    description: This test will run if test 'pass_test' is in state 'PASS'
    status:
      state: FAIL
    needs:
      - pass_test:
          state: PASS
    run: |
      echo "This test will fail"
      sleep 2

  pass_and_fail_test:
    type: script
    executor: generic.local.bash
    description: This test will run if pass_test is 'PASS' and fail_test is 'FAIL'
    needs:
      - pass_test:
          state: PASS
      - fail_test:
          state: FAIL
    run: |
      sleep 2
      exit 1
    status:
      returncode: 1

  final_test:
    type: script
    executor: generic.local.bash
    description: Test will run after 'pass_test', 'fail_test', and 'pass_and_fail_test'
    needs:
      - pass_test
      - fail_test
      - pass_and_fail_test:
          returncode: 1
    run: |
      sleep 2
      echo "Hello world"

Let’s build this test and take note all tests are run.

$ buildtest build -b tutorials/job_dependency/ex3.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:46                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/job_dependency/ex3.yml: VALID
Total builder objects created: 4
Total compiler builder: 0
Total script builder: 4
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ pass_test… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will       │            │
│            │            │          │       │       │ always     │            │
│            │            │          │       │       │ pass       │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ fail_test… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will run   │            │
│            │            │          │       │       │ if test    │            │
│            │            │          │       │       │ 'pass_tes… │            │
│            │            │          │       │       │ is in      │            │
│            │            │          │       │       │ state      │            │
│            │            │          │       │       │ 'PASS'     │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ pass_and_… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will run   │            │
│            │            │          │       │       │ if         │            │
│            │            │          │       │       │ pass_test  │            │
│            │            │          │       │       │ is 'PASS'  │            │
│            │            │          │       │       │ and        │            │
│            │            │          │       │       │ fail_test  │            │
│            │            │          │       │       │ is 'FAIL'  │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ final_tes… │ generic.l… │ None     │ None  │ None  │ Test will  │ /home/doc… │
│            │            │          │       │       │ run after  │            │
│            │            │          │       │       │ 'pass_tes… │            │
│            │            │          │       │       │ 'fail_tes… │            │
│            │            │          │       │       │ and        │            │
│            │            │          │       │       │ 'pass_and… │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
pass_test/1292dc4c: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_test/1292dc4c
pass_test/1292dc4c: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_test/1292dc4c/stage
pass_test/1292dc4c: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_test/1292dc4c/pass_test_build.sh
fail_test/85247007: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/fail_test/85247007
fail_test/85247007: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/fail_test/85247007/stage
fail_test/85247007: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/fail_test/85247007/fail_test_build.sh
pass_and_fail_test/0453c738: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_and_fail_test/0453c738
pass_and_fail_test/0453c738: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_and_fail_test/0453c738/stage
pass_and_fail_test/0453c738: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_and_fail_test/0453c738/pass_and_fail_test_build.sh
final_test/1a0debd8: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/final_test/1a0debd8
final_test/1a0debd8: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/final_test/1a0debd8/stage
final_test/1a0debd8: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/final_test/1a0debd8/final_test_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
final_test/1a0debd8 Skipping job because it has job dependency on pass_test/1292dc4c which is in state PENDING
fail_test/85247007 Skipping job because it has job dependency on pass_test/1292dc4c
pass_and_fail_test/0453c738 Skipping job because it has job dependency on pass_test/1292dc4c
pass_test/1292dc4c does not have any dependencies adding test to queue
pass_test/1292dc4c: Running Test via command: bash --norc --noprofile -eo pipefail pass_test_build.sh
pass_test/1292dc4c: Test completed in 2.006978 seconds
pass_test/1292dc4c: Test completed with returncode: 0
pass_test/1292dc4c: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_test/1292dc4c/pass_test.out
pass_test/1292dc4c: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_test/1292dc4c/pass_test.err
In this iteration we are going to run the following tests: [pass_test/1292dc4c]
───────────────────────────────── Iteration 2 ──────────────────────────────────
final_test/1a0debd8 Skipping job because it has job dependency on fail_test/85247007 which is in state PENDING
pass_and_fail_test/0453c738 Skipping job because it has job dependency on fail_test/85247007
fail_test/85247007: Running Test via command: bash --norc --noprofile -eo pipefail fail_test_build.sh
fail_test/85247007: Test completed in 2.007027 seconds
fail_test/85247007: Test completed with returncode: 0
fail_test/85247007: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/fail_test/85247007/fail_test.out
fail_test/85247007: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/fail_test/85247007/fail_test.err
In this iteration we are going to run the following tests: [fail_test/85247007]
───────────────────────────────── Iteration 3 ──────────────────────────────────
final_test/1a0debd8 Skipping job because it has job dependency on pass_and_fail_test/0453c738
pass_and_fail_test/0453c738: Running Test via command: bash --norc --noprofile -eo pipefail pass_and_fail_test_build.sh
pass_and_fail_test/0453c738: Test completed in 2.006974 seconds
pass_and_fail_test/0453c738: Test completed with returncode: 1
pass_and_fail_test/0453c738: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_and_fail_test/0453c738/pass_and_fail_test.out
pass_and_fail_test/0453c738: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/pass_and_fail_test/0453c738/pass_and_fail_test.err
pass_and_fail_test/0453c738: Checking returncode - 1 is matched in list [1]
In this iteration we are going to run the following tests: [pass_and_fail_test/0453c738]
───────────────────────────────── Iteration 4 ──────────────────────────────────
final_test/1a0debd8: Running Test via command: bash --norc --noprofile -eo pipefail final_test_build.sh
final_test/1a0debd8: Test completed in 2.007088 seconds
final_test/1a0debd8: Test completed with returncode: 0
final_test/1a0debd8: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/final_test/1a0debd8/final_test.out
final_test/1a0debd8: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex3/final_test/1a0debd8/final_test.err
In this iteration we are going to run the following tests: [final_test/1a0debd8]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ pass_and_fai │ generic.loc… │ PASS   │ True False    │ 1          │ 2.006974 │
│ l_test/0453c │              │        │ False         │            │          │
│ 738          │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ fail_test/85 │ generic.loc… │ FAIL   │ False False   │ 0          │ 2.007027 │
│ 247007       │              │        │ False         │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ final_test/1 │ generic.loc… │ PASS   │ N/A N/A N/A   │ 0          │ 2.007088 │
│ a0debd8      │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ pass_test/12 │ generic.loc… │ PASS   │ False False   │ 0          │ 2.006978 │
│ 92dc4c       │              │        │ False         │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 3/4 Percentage: 75.000%
Failed Tests: 1/4 Percentage: 25.000%


Adding 4 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_n8bdfsxf.log

In this next example, we have three tests the first test will runtime_test will sleep for 5 seconds but it will fail due to runtime requirement of 2sec. The next two tests runtime_test_pass and runtime_test_fail both depend on runtime_test however due to condition only one of them can be run because runtime_test_pass expects runtime_test to have state: PASS while runtime_test_fail expects runtime_test to have state: FAIL. This type of workflow can be used if you want to run a set of test based on one condition while running a different set of test based on the negative condition.

buildspecs:
  runtime_test:
    type: script
    executor: generic.local.bash
    description: This test will sleep 5 second but will fail due to runtime 2sec
    status:
      runtime:
        min: 2.0
    run: sleep 5

  runtime_test_pass:
    type: script
    executor: generic.local.bash
    description: This test will run when runtime_test_pass is PASS
    needs:
      - runtime_test:
          state: PASS
    run: echo "Performing some action when test PASS"

  runtime_test_fail:
    type: script
    executor: generic.local.bash
    description: This test will run when runtime_test_pass is FAIL
    needs:
      - runtime_test:
          state: FAIL
    run: echo "Performing some action when test FAIL"

Let’s build this test and take note that we only run two tests and runtime_test_fail was skipped because test runtime_test has a state: PASS.

$ buildtest build -b tutorials/job_dependency/ex4.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:19:55                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/job_dependency/ex4.yml: VALID
Total builder objects created: 3
Total compiler builder: 0
Total script builder: 3
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ runtime_t… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will sleep │            │
│            │            │          │       │       │ 5 second   │            │
│            │            │          │       │       │ but will   │            │
│            │            │          │       │       │ fail due   │            │
│            │            │          │       │       │ to runtime │            │
│            │            │          │       │       │ 2sec       │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ runtime_t… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will run   │            │
│            │            │          │       │       │ when       │            │
│            │            │          │       │       │ runtime_t… │            │
│            │            │          │       │       │ is PASS    │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ runtime_t… │ generic.l… │ None     │ None  │ None  │ This test  │ /home/doc… │
│            │            │          │       │       │ will run   │            │
│            │            │          │       │       │ when       │            │
│            │            │          │       │       │ runtime_t… │            │
│            │            │          │       │       │ is FAIL    │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
runtime_test/d05b60b8: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test/d05b60b8
runtime_test/d05b60b8: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test/d05b60b8/stage
runtime_test/d05b60b8: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test/d05b60b8/runtime_test_build.sh
runtime_test_pass/f36b014a: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_pass/f36b014a
runtime_test_pass/f36b014a: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_pass/f36b014a/stage
runtime_test_pass/f36b014a: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_pass/f36b014a/runtime_test_pass_build.sh
runtime_test_fail/edbe2c31: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_fail/edbe2c31
runtime_test_fail/edbe2c31: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_fail/edbe2c31/stage
runtime_test_fail/edbe2c31: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_fail/edbe2c31/runtime_test_fail_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
runtime_test_pass/f36b014a Skipping job because it has job dependency on runtime_test/d05b60b8
runtime_test_fail/edbe2c31 Skipping job because it has job dependency on runtime_test/d05b60b8
runtime_test/d05b60b8 does not have any dependencies adding test to queue
runtime_test/d05b60b8: Running Test via command: bash --norc --noprofile -eo pipefail runtime_test_build.sh
runtime_test/d05b60b8: Test completed in 5.006921 seconds
runtime_test/d05b60b8: Test completed with returncode: 0
runtime_test/d05b60b8: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test/d05b60b8/runtime_test.out
runtime_test/d05b60b8: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test/d05b60b8/runtime_test.err
In this iteration we are going to run the following tests: [runtime_test/d05b60b8]
───────────────────────────────── Iteration 2 ──────────────────────────────────
runtime_test_fail/edbe2c31 is cancelled because it depends on runtime_test/d05b60b8 to have state: FAIL but actual value is PASS
runtime_test_pass/f36b014a: Running Test via command: bash --norc --noprofile -eo pipefail runtime_test_pass_build.sh
runtime_test_pass/f36b014a: Test completed in 0.005619 seconds
runtime_test_pass/f36b014a: Test completed with returncode: 0
runtime_test_pass/f36b014a: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_pass/f36b014a/runtime_test_pass.out
runtime_test_pass/f36b014a: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/ex4/runtime_test_pass/f36b014a/runtime_test_pass.err
In this iteration we are going to run the following tests: [runtime_test_pass/f36b014a]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ runtime_test │ generic.loc… │ PASS   │ N/A N/A N/A   │ 0          │ 0.005619 │
│ _pass/f36b01 │              │        │               │            │          │
│ 4a           │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ runtime_test │ generic.loc… │ PASS   │ False False   │ 0          │ 5.006921 │
│ /d05b60b8    │              │        │ True          │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 2/2 Percentage: 100.000%
Failed Tests: 0/2 Percentage: 0.000%


Adding 2 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_qfklysqy.log

Running test across multiple executors

The executor property can support regular expression to search for compatible executors, this can be used if you want to run a test across multiple executors. In buildtest, we use re.fullmatch with the input pattern defined by executor property against a list of available executors defined in configuration file. You can retrieve a list of executors by running buildtest config executors.

In example below we will run this test on generic.local.bash and generic.local.sh executor based on the regular expression.

buildspecs:
  multiple_executors:
    type: script
    executor: 'generic.local.(bash|sh)'
    description: run test with executor generic.local.bash and generic.local.sh executor
    tags: [tutorials]
    run: date

If we build this test, notice that there are two tests, one for each executor.

$ buildtest build -b tutorials/multi_executors/executor_regex_script.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:20:01                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/multi_executors/executor_regex_script.yml: VALID
Total builder objects created: 2
Total compiler builder: 0
Total script builder: 2
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ multiple_… │ generic.l… │ None     │ None  │ None  │ run test   │ /home/doc… │
│            │            │          │       │       │ with       │            │
│            │            │          │       │       │ executor   │            │
│            │            │          │       │       │ generic.l… │            │
│            │            │          │       │       │ and        │            │
│            │            │          │       │       │ generic.l… │            │
│            │            │          │       │       │ executor   │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ multiple_… │ generic.l… │ None     │ None  │ None  │ run test   │ /home/doc… │
│            │            │          │       │       │ with       │            │
│            │            │          │       │       │ executor   │            │
│            │            │          │       │       │ generic.l… │            │
│            │            │          │       │       │ and        │            │
│            │            │          │       │       │ generic.l… │            │
│            │            │          │       │       │ executor   │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
multiple_executors/95a746ee: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_regex_script/multiple_executors/95a746ee
multiple_executors/95a746ee: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_regex_script/multiple_executors/95a746ee/stage
multiple_executors/95a746ee: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_regex_script/multiple_executors/95a746ee/multiple_executors_build.sh
multiple_executors/86b2434d: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_regex_script/multiple_executors/86b2434d
multiple_executors/86b2434d: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_regex_script/multiple_executors/86b2434d/stage
multiple_executors/86b2434d: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_regex_script/multiple_executors/86b2434d/multiple_executors_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
multiple_executors/95a746ee does not have any dependencies adding test to queue
multiple_executors/86b2434d does not have any dependencies adding test to queue
multiple_executors/95a746ee: Running Test via command: bash --norc --noprofile -eo pipefail multiple_executors_build.sh
multiple_executors/95a746ee: Test completed in 0.00771 seconds
multiple_executors/95a746ee: Test completed with returncode: 0
multiple_executors/95a746ee: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_regex_script/multiple_executors/95a746ee/multiple_executors.out
multiple_executors/95a746ee: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_regex_script/multiple_executors/95a746ee/multiple_executors.err
multiple_executors/86b2434d: Running Test via command: sh --norc --noprofile -eo pipefail multiple_executors_build.sh
multiple_executors/86b2434d: Test completed in 0.003083 seconds
multiple_executors/86b2434d: Test completed with returncode: 2
multiple_executors/86b2434d: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_regex_script/multiple_executors/86b2434d/multiple_executors.out
multiple_executors/86b2434d: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_regex_script/multiple_executors/86b2434d/multiple_executors.err
In this iteration we are going to run the following tests: [multiple_executors/95a746ee, multiple_executors/86b2434d]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ multiple_exe │ generic.loc… │ PASS   │ N/A N/A N/A   │ 0          │ 0.00771  │
│ cutors/95a74 │              │        │               │            │          │
│ 6ee          │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ multiple_exe │ generic.loc… │ FAIL   │ N/A N/A N/A   │ 2          │ 0.003083 │
│ cutors/86b24 │              │        │               │            │          │
│ 34d          │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 1/2 Percentage: 50.000%
Failed Tests: 1/2 Percentage: 50.000%


Adding 2 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_nfpozvag.log

Multiple Executors

Note

This feature is in active development

Note

This feature is compatible with type: script and type: spack.

The executors property can be used to define executor specific configuration for each test, currently this field can be used with vars, env , scheduler directives: sbatch, bsub, pbs, cobalt and cray burst buffer/data warp. The executors field is a JSON object that expects name of executor followed by property set per executor. In this next example, we define variables X, Y and environment SHELL based on executors generic.local.sh and generic.local.bash.

buildspecs:
  executors_vars_env_declaration:
    type: script
    executor: 'generic.local.(bash|sh)'
    description: Declaring env and vars by executors section
    tags: [tutorials]
    run: |
      echo "X:" $X
      echo "Y:" $Y
      echo $SHELL
    executors:
      generic.local.bash:
        vars:
          X: 1
          Y: 3
        env:
          SHELL: bash
      generic.local.sh:
        vars:
          X: 2
          Y: 4
        env:
          SHELL: sh

Let’s build this test.

$ buildtest build -b tutorials/multi_executors/executors_var_env_declaration.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:20:01                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/multi_executors/executors_var_env_declaration.yml: VALID
Total builder objects created: 2
Total compiler builder: 0
Total script builder: 2
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ executors… │ generic.l… │ None     │ None  │ None  │ Declaring  │ /home/doc… │
│            │            │          │       │       │ env and    │            │
│            │            │          │       │       │ vars by    │            │
│            │            │          │       │       │ executors  │            │
│            │            │          │       │       │ section    │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ executors… │ generic.l… │ None     │ None  │ None  │ Declaring  │ /home/doc… │
│            │            │          │       │       │ env and    │            │
│            │            │          │       │       │ vars by    │            │
│            │            │          │       │       │ executors  │            │
│            │            │          │       │       │ section    │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
executors_vars_env_declaration/dc6616dd: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd
executors_vars_env_declaration/dc6616dd: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/stage
executors_vars_env_declaration/dc6616dd: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/executors_vars_env_declaration_build.sh
executors_vars_env_declaration/8136cc85: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85
executors_vars_env_declaration/8136cc85: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/stage
executors_vars_env_declaration/8136cc85: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/executors_vars_env_declaration_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
executors_vars_env_declaration/dc6616dd does not have any dependencies adding test to queue
executors_vars_env_declaration/8136cc85 does not have any dependencies adding test to queue
executors_vars_env_declaration/dc6616dd: Running Test via command: bash --norc --noprofile -eo pipefail executors_vars_env_declaration_build.sh
executors_vars_env_declaration/dc6616dd: Test completed in 0.006176 seconds
executors_vars_env_declaration/dc6616dd: Test completed with returncode: 0
executors_vars_env_declaration/dc6616dd: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/executors_vars_env_declaration.out
executors_vars_env_declaration/dc6616dd: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/executors_vars_env_declaration.err
executors_vars_env_declaration/8136cc85: Running Test via command: sh --norc --noprofile -eo pipefail executors_vars_env_declaration_build.sh
executors_vars_env_declaration/8136cc85: Test completed in 0.003416 seconds
executors_vars_env_declaration/8136cc85: Test completed with returncode: 2
executors_vars_env_declaration/8136cc85: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/executors_vars_env_declaration.out
executors_vars_env_declaration/8136cc85: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/executors_vars_env_declaration.err
In this iteration we are going to run the following tests: [executors_vars_env_declaration/dc6616dd, executors_vars_env_declaration/8136cc85]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ executors_va │ generic.loc… │ PASS   │ N/A N/A N/A   │ 0          │ 0.006176 │
│ rs_env_decla │              │        │               │            │          │
│ ration/dc661 │              │        │               │            │          │
│ 6dd          │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ executors_va │ generic.loc… │ FAIL   │ N/A N/A N/A   │ 2          │ 0.003416 │
│ rs_env_decla │              │        │               │            │          │
│ ration/8136c │              │        │               │            │          │
│ c85          │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 1/2 Percentage: 50.000%
Failed Tests: 1/2 Percentage: 50.000%


Adding 2 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_srsxtd7h.log

Now let’s look at the generated content of the test as follows. We will see that buildtest will set X=1, Y=3 and SHELL=bash for generic.local.bash and X=2, Y=4 and SHELL=sh for generic.local.sh

$ buildtest inspect query -t executors_vars_env_declaration/
───── executors_vars_env_declaration/dc6616dd-bcd0-49b0-835e-b2ca9758ee3d ──────
Executor: generic.local.bash
Description: Declaring env and vars by executors section
State: PASS
Returncode: 0
Runtime: 0.006176 sec
Starttime: 2022/08/17 19:20:01
Endtime: 2022/08/17 19:20:01
Command: bash --norc --noprofile -eo pipefail executors_vars_env_declaration_build.sh
Test Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/executors_vars_env_declaration.sh
Build Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/executors_vars_env_declaration_build.sh
Output File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/executors_vars_env_declaration.out
Error File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executors_var_env_declaration/executors_vars_env_declaration/dc6616dd/executors_vars_env_declaration.err
Log File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_srsxtd7h.log
─ Test File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/check… ─
#!/usr/bin/bash                                                                 
export SHELL="bash"                                                             
X="1"                                                                           
Y="3"                                                                           
# Content of run section                                                        
echo "X:" $X                                                                    
echo "Y:" $Y                                                                    
echo $SHELL                                                                     
                                                                                
───── executors_vars_env_declaration/8136cc85-b65e-4bf1-94e8-9422b3c61148 ──────
Executor: generic.local.sh
Description: Declaring env and vars by executors section
State: FAIL
Returncode: 2
Runtime: 0.003416 sec
Starttime: 2022/08/17 19:20:01
Endtime: 2022/08/17 19:20:01
Command: sh --norc --noprofile -eo pipefail executors_vars_env_declaration_build.sh
Test Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/executors_vars_env_declaration.sh
Build Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/executors_vars_env_declaration_build.sh
Output File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/executors_vars_env_declaration.out
Error File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executors_var_env_declaration/executors_vars_env_declaration/8136cc85/executors_vars_env_declaration.err
Log File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_srsxtd7h.log
─ Test File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/check… ─
#!/usr/bin/sh                                                                   
export SHELL="sh"                                                               
X="2"                                                                           
Y="4"                                                                           
# Content of run section                                                        
echo "X:" $X                                                                    
echo "Y:" $Y                                                                    
echo $SHELL

Scheduler Directives

We can also define scheduler directives based on executor type, in this example we define sbatch property per executor type. Note that sbatch property in the executors section will override the sbatch property defined in the top-level file otherwise it will use the default.

buildspecs:
  executors_sbatch_declaration:
    type: script
    executor: 'generic.local.(bash|sh)'
    description: Declaring env and vars by executors section
    tags: [tutorials]
    run: hostname
    sbatch: ["-N 4"]
    executors:
      generic.local.bash:
        sbatch: ["-n 4", "-N 1", "-t 30"]
      generic.local.sh:
        sbatch: ["-n 8", "-N 1", "-t 60"]
$ buildtest build -b tutorials/multi_executors/executor_scheduler.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:20:02                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/multi_executors/executor_scheduler.yml: VALID
Total builder objects created: 2
Total compiler builder: 0
Total script builder: 2
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ executors… │ generic.l… │ None     │ None  │ None  │ Declaring  │ /home/doc… │
│            │            │          │       │       │ env and    │            │
│            │            │          │       │       │ vars by    │            │
│            │            │          │       │       │ executors  │            │
│            │            │          │       │       │ section    │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ executors… │ generic.l… │ None     │ None  │ None  │ Declaring  │ /home/doc… │
│            │            │          │       │       │ env and    │            │
│            │            │          │       │       │ vars by    │            │
│            │            │          │       │       │ executors  │            │
│            │            │          │       │       │ section    │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
executors_sbatch_declaration/bd21c115: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115
executors_sbatch_declaration/bd21c115: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/stage
executors_sbatch_declaration/bd21c115: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/executors_sbatch_declaration_build.sh
executors_sbatch_declaration/f1193e42: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42
executors_sbatch_declaration/f1193e42: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/stage
executors_sbatch_declaration/f1193e42: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/executors_sbatch_declaration_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
executors_sbatch_declaration/f1193e42 does not have any dependencies adding test to queue
executors_sbatch_declaration/bd21c115 does not have any dependencies adding test to queue
executors_sbatch_declaration/f1193e42: Running Test via command: sh --norc --noprofile -eo pipefail executors_sbatch_declaration_build.sh
executors_sbatch_declaration/f1193e42: Test completed in 0.003484 seconds
executors_sbatch_declaration/f1193e42: Test completed with returncode: 2
executors_sbatch_declaration/f1193e42: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/executors_sbatch_declaration.out
executors_sbatch_declaration/f1193e42: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/executors_sbatch_declaration.err
executors_sbatch_declaration/bd21c115: Running Test via command: bash --norc --noprofile -eo pipefail executors_sbatch_declaration_build.sh
executors_sbatch_declaration/bd21c115: Test completed in 0.006889 seconds
executors_sbatch_declaration/bd21c115: Test completed with returncode: 0
executors_sbatch_declaration/bd21c115: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/executors_sbatch_declaration.out
executors_sbatch_declaration/bd21c115: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/executors_sbatch_declaration.err
In this iteration we are going to run the following tests: [executors_sbatch_declaration/f1193e42, executors_sbatch_declaration/bd21c115]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ executors_sb │ generic.loc… │ FAIL   │ N/A N/A N/A   │ 2          │ 0.003484 │
│ atch_declara │              │        │               │            │          │
│ tion/f1193e4 │              │        │               │            │          │
│ 2            │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ executors_sb │ generic.loc… │ PASS   │ N/A N/A N/A   │ 0          │ 0.006889 │
│ atch_declara │              │        │               │            │          │
│ tion/bd21c11 │              │        │               │            │          │
│ 5            │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 1/2 Percentage: 50.000%
Failed Tests: 1/2 Percentage: 50.000%


Adding 2 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_30txa2ku.log

If we inspect this test, we will see each each test have different #SBATCH directives for each test based on the sbatch property defined in the executors field.

$ buildtest inspect query -t executors_sbatch_declaration/
────── executors_sbatch_declaration/bd21c115-12f9-441a-9788-7f8781d47cab ───────
Executor: generic.local.bash
Description: Declaring env and vars by executors section
State: PASS
Returncode: 0
Runtime: 0.006889 sec
Starttime: 2022/08/17 19:20:02
Endtime: 2022/08/17 19:20:02
Command: bash --norc --noprofile -eo pipefail executors_sbatch_declaration_build.sh
Test Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/executors_sbatch_declaration.sh
Build Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/executors_sbatch_declaration_build.sh
Output File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/executors_sbatch_declaration.out
Error File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/executor_scheduler/executors_sbatch_declaration/bd21c115/executors_sbatch_declaration.err
Log File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_30txa2ku.log
─ Test File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/check… ─
#!/usr/bin/bash                                                                 
#SBATCH -n 4                                                                    
#SBATCH -N 1                                                                    
#SBATCH -t 30                                                                   
#SBATCH --job-name=executors_sbatch_declaration                                 
#SBATCH --output=executors_sbatch_declaration.out                               
#SBATCH --error=executors_sbatch_declaration.err                                
# Content of run section                                                        
hostname                                                                        
────── executors_sbatch_declaration/f1193e42-a0c1-4bcd-8b8a-7358f5aa912a ───────
Executor: generic.local.sh
Description: Declaring env and vars by executors section
State: FAIL
Returncode: 2
Runtime: 0.003484 sec
Starttime: 2022/08/17 19:20:02
Endtime: 2022/08/17 19:20:02
Command: sh --norc --noprofile -eo pipefail executors_sbatch_declaration_build.sh
Test Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/executors_sbatch_declaration.sh
Build Script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/executors_sbatch_declaration_build.sh
Output File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/executors_sbatch_declaration.out
Error File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/executor_scheduler/executors_sbatch_declaration/f1193e42/executors_sbatch_declaration.err
Log File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_30txa2ku.log
─ Test File: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/check… ─
#!/usr/bin/sh                                                                   
#SBATCH -n 8                                                                    
#SBATCH -N 1                                                                    
#SBATCH -t 60                                                                   
#SBATCH --job-name=executors_sbatch_declaration                                 
#SBATCH --output=executors_sbatch_declaration.out                               
#SBATCH --error=executors_sbatch_declaration.err                                
# Content of run section                                                        
hostname

Cray Burst Buffer and Data Warp

You can also define BB and DW directives in the executors field to override cray burst buffer and data warp settings per executor. buildtest will use the fields BB and DW and insert the #BB and #DW directives in the job script. For more details see Cray Burst Buffer & Data Warp.

buildspecs:
  create_burst_buffer_multiple_executors:
    type: script
    executor: "generic.local.(sh|bash)"
    sbatch: ["-N 1", "-t 10", "-C knl"]
    description: Create a burst buffer for multiple executors
    tags: [jobs]
    executors:
      generic.local.sh:
        BB:
          - create_persistent name=buffer1 capacity=10GB access_mode=striped type=scratch
        DW:
          - persistentdw name=buffer1
      generic.local.bash:
        BB:
        - create_persistent name=buffer2 capacity=10GB access_mode=striped type=scratch
        DW:
          - persistentdw name=buffer2
    run: hostname

Custom Status by Executor

The status and metrics field are supported in executors which can be defined within the named executor. In this next example, we will define executor generic.local.bash to match for returncode 0 or 2 while second test will use executor generic.local.sh to match returncode of 1.

buildspecs:
  status_returncode_by_executors:
    type: script
    executor: "generic.local.(bash|sh)"
    description: define status per executor type.
    tags: [tutorials]
    run: exit 0
    executors:
      generic.local.bash:
        status:
          returncode: [0, 2]
      generic.local.sh:
        status:
          returncode: 1

Now let’s run this test and we will see the test using executor generic.local.sh will fail because we have a returncode mismatch even though both tests got a 0 returncode as its actual value.

$ buildtest build -b tutorials/multi_executors/status_by_executors.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│                                                                              │
│ User:               docs                                                     │
│ Hostname:           build-17824374-project-280831-buildtest                  │
│ Platform:           Linux                                                    │
│ Current Time:       2022/08/17 19:20:03                                      │
│ buildtest path:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version:  0.15.0                                                   │
│ python path:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version:     3.7.13                                                   │
│ Configuration File: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Test Directory:     /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Report File:        /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ Command:            /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
───────────────────────────  Discovering Buildspecs ────────────────────────────
                             Discovered buildspecs                              
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec                                                                    ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/… ║
╚══════════════════════════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Buildtest will parse 1 buildspecs
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/tutorials/multi_executors/status_by_executors.yml: VALID
Total builder objects created: 2
Total compiler builder: 0
Total script builder: 2
Total spack builder: 0
                             Script Builder Details                             
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ builder    ┃ executor   ┃ compiler ┃ nodes ┃ procs ┃ descripti… ┃ buildspecs ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ status_re… │ generic.l… │ None     │ None  │ None  │ define     │ /home/doc… │
│            │            │          │       │       │ status per │            │
│            │            │          │       │       │ executor   │            │
│            │            │          │       │       │ type.      │            │
├────────────┼────────────┼──────────┼───────┼───────┼────────────┼────────────┤
│ status_re… │ generic.l… │ None     │ None  │ None  │ define     │ /home/doc… │
│            │            │          │       │       │ status per │            │
│            │            │          │       │       │ executor   │            │
│            │            │          │       │       │ type.      │            │
└────────────┴────────────┴──────────┴───────┴───────┴────────────┴────────────┘
──────────────────────────────── Building Test ─────────────────────────────────
status_returncode_by_executors/b59faa60: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_by_executors/status_returncode_by_executors/b59faa60
status_returncode_by_executors/b59faa60: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_by_executors/status_returncode_by_executors/b59faa60/stage
status_returncode_by_executors/b59faa60: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_by_executors/status_returncode_by_executors/b59faa60/status_returncode_by_executors_build.sh
status_returncode_by_executors/e6b29e9b: Creating test directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/status_by_executors/status_returncode_by_executors/e6b29e9b
status_returncode_by_executors/e6b29e9b: Creating the stage directory: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/status_by_executors/status_returncode_by_executors/e6b29e9b/stage
status_returncode_by_executors/e6b29e9b: Writing build script: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/status_by_executors/status_returncode_by_executors/e6b29e9b/status_returncode_by_executors_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
status_returncode_by_executors/e6b29e9b does not have any dependencies adding test to queue
status_returncode_by_executors/b59faa60 does not have any dependencies adding test to queue
status_returncode_by_executors/e6b29e9b: Running Test via command: sh --norc --noprofile -eo pipefail status_returncode_by_executors_build.sh
status_returncode_by_executors/e6b29e9b: Test completed in 0.003585 seconds
status_returncode_by_executors/e6b29e9b: Test completed with returncode: 2
status_returncode_by_executors/e6b29e9b: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/status_by_executors/status_returncode_by_executors/e6b29e9b/status_returncode_by_executors.out
status_returncode_by_executors/e6b29e9b: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.sh/status_by_executors/status_returncode_by_executors/e6b29e9b/status_returncode_by_executors.err
status_returncode_by_executors/e6b29e9b: Checking returncode - 2 is matched in list [1]
status_returncode_by_executors/b59faa60: Running Test via command: bash --norc --noprofile -eo pipefail status_returncode_by_executors_build.sh
status_returncode_by_executors/b59faa60: Test completed in 0.005703 seconds
status_returncode_by_executors/b59faa60: Test completed with returncode: 0
status_returncode_by_executors/b59faa60: Writing output file -  /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_by_executors/status_returncode_by_executors/b59faa60/status_returncode_by_executors.out
status_returncode_by_executors/b59faa60: Writing error file - /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/tests/generic.local.bash/status_by_executors/status_returncode_by_executors/b59faa60/status_returncode_by_executors.err
status_returncode_by_executors/b59faa60: Checking returncode - 0 is matched in list [0, 2]
In this iteration we are going to run the following tests: [status_returncode_by_executors/e6b29e9b, status_returncode_by_executors/b59faa60]
                                  Test Summary                                  
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃              ┃              ┃        ┃ checks        ┃            ┃          ┃
┃              ┃              ┃        ┃ (ReturnCode,  ┃            ┃          ┃
┃              ┃              ┃        ┃ Regex,        ┃            ┃          ┃
┃ builder      ┃ executor     ┃ status ┃ Runtime)      ┃ returnCode ┃ runtime  ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ status_retur │ generic.loc… │ PASS   │ True False    │ 0          │ 0.005703 │
│ ncode_by_exe │              │        │ False         │            │          │
│ cutors/b59fa │              │        │               │            │          │
│ a60          │              │        │               │            │          │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ status_retur │ generic.loc… │ FAIL   │ False False   │ 2          │ 0.003585 │
│ ncode_by_exe │              │        │ False         │            │          │
│ cutors/e6b29 │              │        │               │            │          │
│ e9b          │              │        │               │            │          │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘



Passed Tests: 1/2 Percentage: 50.000%
Failed Tests: 1/2 Percentage: 50.000%


Adding 2 test results to /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/report.json
Writing Logfile to: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/devel/var/logs/buildtest_8i9l8s1j.log