Buildspecs Interface

Now that we learned how to build tests, in this section we will discuss how one can query a buildspec cache. In buildtest, one can load all buildspecs which is equivalent to validating all buildspecs with the appropriate schema. Buildtest will ignore all invalid buildspecs and store them in a separate file.

Note

buildtest bc is an alias for buildtest buildspec command.

Finding Buildspecs - buildtest buildspec find

The buildtest buildspec find command is used for finding buildspecs from buildspec cache. This command is also used for generating the buildspec cache. Shown below is a list of options for provided for this command.

buildtest buildspec find --help
$ buildtest buildspec find --help
usage: buildtest [options] [COMMANDS] buildspec find [-h] [--pager]
                                                     [--row-count] [--terse]
                                                     [-n] [-c COUNT] [-b] [-e]
                                                     [--group-by-tags]
                                                     [--group-by-executor]
                                                     [-p] [-t]
                                                     [--filter FILTER]
                                                     [--format FORMAT]
                                                     [--helpfilter]
                                                     [--helpformat]
                                                     [--filterfields]
                                                     [--formatfields] [-r]
                                                     [--root ROOT] [-q]
                                                     ...

positional arguments:
  
    invalid             Show invalid buildspecs

optional arguments:
  -h, --help            show this help message and exit
  --pager               Enable PAGING when viewing result
  --row-count           Display number of rows from query shown in table
  --terse               Print output in machine readable format
  -n, --no-header       Do not print header columns in terse output (--terse)
  -c COUNT, --count COUNT
                        Retrieve limited number of rows that get printed

query:
  query options to retrieve from buildspec cache

  -b, --buildspec       Get all buildspec files from cache
  -e, --executors       Get all unique executors from buildspecs
  --group-by-tags       Group tests by tag name
  --group-by-executor   Group tests by executor name
  -p, --paths           Print all root buildspec paths
  -t, --tags            List all available tags

filter:
  filter and format options

  --filter FILTER       Filter buildspec cache with filter fields in format
                        --filter key1=val1,key2=val2
  --format FORMAT       Format buildspec cache with format fields in format
                        --format field1,field2,...
  --helpfilter          Show Filter fields for --filter option for filtering
                        buildspec cache output
  --helpformat          Show Format fields for --format option for formatting
                        buildspec cache output
  --filterfields        Print raw Filter fields for --filter option for
                        filtering buildspec cache output
  --formatfields        Print raw Format fields for --format option for
                        formatting buildspec cache output

extra:
  All extra options

  -r, --rebuild         Rebuild buildspec cache and find all buildspecs again
  --root ROOT           Specify root buildspecs (directory) path to load
                        buildspecs into buildspec cache.
  -q, --quiet           Don't print output of buildspec cache when rebuilding
                        cache

The buildtest buildspec find command will discover all buildspecs by recursively searching all .yml extensions. buildtest will validate each buildspec file with the json schema and buildtest will display all valid buildspecs in the output, all invalid buildspecs will be stored in a file for post-processing.

buildtest buildspec find
$ buildtest buildspec find
          Buildspec Cache: /tmp/tmpxadaezwi/var/buildspecs/cache.json           
 name              ┃ type   ┃ executor          ┃ tags      ┃ description       
━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━
 bash_login_sheban │ script │ generic.local.bas │ tutorials │ customize shebang 
 g                 │        │ h                 │           │ line with bash    
                   │        │                   │           │ login shell       
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 bash_nonlogin_she │ script │ generic.local.bas │ tutorials │ customize shebang 
 bang              │        │ h                 │           │ line with default 
                   │        │                   │           │ bash (nonlogin)   
                   │        │                   │           │ shell             
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 create_burst_buff │ script │ generic.local.(sh │ jobs      │ Create a burst    
 er_executors      │        │ |bash)            │           │ buffer for        
                   │        │                   │           │ multiple          
                   │        │                   │           │ executors         
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 _bin_sh_shell     │ script │ generic.local.sh  │ tutorials │ /bin/sh shell     
                   │        │                   │           │ example           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 _bin_bash_shell   │ script │ generic.local.bas │ tutorials │ /bin/bash shell   
                   │        │ h                 │           │ example           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 bash_shell        │ script │ generic.local.bas │ tutorials │ bash shell        
                   │        │ h                 │           │ example           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 sh_shell          │ script │ generic.local.sh  │ tutorials │ sh shell example  
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 shell_options     │ script │ generic.local.sh  │ tutorials │ shell options     
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 skip_all_tests    │ script │ generic.local.bas │ tutorials │ All test in this  
                   │        │ h                 │           │ buildspec are     
                   │        │                   │           │ skipped           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 this_test_is_also │ script │ generic.local.bas │ tutorials │ This test is also 
 _skipped          │        │ h                 │           │ skipped even if   
                   │        │                   │           │ skip is defined   
                   │        │                   │           │ in test           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 python_hello      │ script │ generic.local.bas │ python    │ Hello World       
                   │        │ h                 │           │ python            
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 foo_bar           │ script │ generic.local.sh  │ tutorials │ prints variable   
                   │        │                   │           │ $FOO              
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 csh_shell         │ script │ generic.local.csh │ tutorials │ csh shell example 
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 skip              │ script │ generic.local.bas │ tutorials │ This test is      
                   │        │ h                 │           │ skipped           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 unskipped         │ script │ generic.local.bas │ tutorials │ This test is not  
                   │        │ h                 │           │ skipped

buildtest will load all discovered buildspecs in a cache file (JSON) which is created upon running buildtest buildspec find. Any subsequent runs will read from cache and update if any new buildspecs are added. If you make changes to buildspec you should rebuild the buildspec cache by running:

$ buildtest buildspec find --rebuild

The --quiet option can be used to suppress output when using buildtest buildspec find this can be useful if you want to rebuild the cache without seeing output of cache. Take for instance the following command

buildtest buildspec find --quiet --rebuild
$ buildtest buildspec find --quiet --rebuild
Clearing cache file: /tmp/tmpxadaezwi/var/buildspecs/cache.json
Buildspec Paths: ['/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials', '/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/general_tests']
Updating buildspec cache file: /tmp/tmpxadaezwi/var/buildspecs/cache.json

If you want to limit the number of entries to display in output, you can use --count option which expects a positive number. For instance let’s limit output to 5 entries, we can run the following

buildtest buildspec find --count=5
$ buildtest buildspec find --count=5
          Buildspec Cache: /tmp/tmpxadaezwi/var/buildspecs/cache.json           
 name              ┃ type   ┃ executor          ┃ tags      ┃ description       
━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━
 bash_login_sheban │ script │ generic.local.bas │ tutorials │ customize shebang 
 g                 │        │ h                 │           │ line with bash    
                   │        │                   │           │ login shell       
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 bash_nonlogin_she │ script │ generic.local.bas │ tutorials │ customize shebang 
 bang              │        │ h                 │           │ line with default 
                   │        │                   │           │ bash (nonlogin)   
                   │        │                   │           │ shell             
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 create_burst_buff │ script │ generic.local.(sh │ jobs      │ Create a burst    
 er_executors      │        │ |bash)            │           │ buffer for        
                   │        │                   │           │ multiple          
                   │        │                   │           │ executors         
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 _bin_sh_shell     │ script │ generic.local.sh  │ tutorials │ /bin/sh shell     
                   │        │                   │           │ example           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 _bin_bash_shell   │ script │ generic.local.bas │ tutorials │ /bin/bash shell   
                   │        │ h                 │           │ example

You can use the --row-count option to retrieve total number of records from the buildtest buildspec find query. In the next example, we show retrieved number of tests available in the buildspec cache by running the following.

buildtest buildspec find --row-count
$ buildtest buildspec find --row-count
15

You may find it useful to use the --row-count feature while filtering the buildspec cache. For instance, you can get the number of buildspecs in the cache with the script schema type, this can be done by running buildtest bc find --filter type=script --row-count as shown below.

buildtest buildspec find --filter type=script --row-count
$ buildtest buildspec find --filter type=script --row-count
15

Finding buildspec files

If you want to find all buildspec files in cache you can run buildtest buildspec find --buildspec. Shown below is an example output.

buildtest buildspec find --buildspec
$ buildtest buildspec find --buildspec
                               List of Buildspecs                               
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Buildspecs                                                                   ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/ │
│ tutorials/shebang.yml                                                        │
│ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/ │
│ tutorials/burstbuffer_datawarp_executors.yml                                 │
│ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/ │
│ tutorials/shell_examples.yml                                                 │
│ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/ │
...

Find root paths where buildspecs are searched

The buildtest buildspec find --paths will display a list of root directories buildtest will search for buildspecs when running buildtest buildspec find. One can define these directories in the configuration file or pass them via command line.

buildtest buildspec find --paths
$ buildtest buildspec find --paths
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/general_tests

buildtest will search buildspecs in buildspecs root defined in your configuration, which is a list of directory paths to search for buildspecs. If you want to load buildspecs from a directory path, you can specify a directory via --root option in the format: buildtest buildspec find --root <path> --rebuild. buildtest will load all valid buildspecs into cache and ignore the rest. It’s important to add --rebuild if you want to regenerate buildspec cache.

Filtering buildspec

Once you have a buildspec cache, we can query the buildspec cache for certain attributes. When you run buildtest buildspec find it will report all buildspecs from cache which can be difficult to process. Therefore, we have a filter option (--filter) to restrict our search. Let’s take a look at the available filter fields that are acceptable with filter option.

buildtest buildspec find --helpfilter
$ buildtest buildspec find --helpfilter
                Filter Field Description                
┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
┃ Field      ┃ Type                      ┃ Description ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
│ buildspecs │ Filter tests by buildspec │ FILE        │
├────────────┼───────────────────────────┼─────────────┤
│ executor   │ Filter by executor name   │ STRING      │
├────────────┼───────────────────────────┼─────────────┤
│ tags       │ Filter by tag name        │ STRING      │
├────────────┼───────────────────────────┼─────────────┤
│ type       │ Filter by schema type     │ STRING      │
└────────────┴───────────────────────────┴─────────────┘

The --filter option expects an arguments in key=value format as follows:

buildtest buildspec find --filter key1=value1,key2=value2,key3=value3

We can filter buildspec cache by tags=fail which will query all tests with associated tag field in test.

buildtest buildspec find --filter tags=fail
$ buildtest buildspec find --filter tags=fail
          Buildspec Cache: /tmp/tmpxadaezwi/var/buildspecs/cache.json           
 name            ┃ type   ┃ executor         ┃ tags           ┃ description     
━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━
 exit1_fail      │ script │ generic.local.ba │ tutorials fail │ exit 1 by       
                 │        │ sh               │                │ default is FAIL 
─────────────────┼────────┼──────────────────┼────────────────┼─────────────────
 returncode_list │ script │ generic.local.ba │ tutorials fail │ exit 2 failed   
 _mismatch       │        │ sh               │                │ since it failed 
                 │        │                  │                │ to match        
                 │        │                  │                │ returncode 1

In addition, we can query buildspecs by schema type using type property. In this example we query all tests by type property

buildtest buildspec find --filter type=script
$ buildtest buildspec find --filter type=script
          Buildspec Cache: /tmp/tmpxadaezwi/var/buildspecs/cache.json           
 name              ┃ type   ┃ executor          ┃ tags      ┃ description       
━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━
 bash_login_sheban │ script │ generic.local.bas │ tutorials │ customize shebang 
 g                 │        │ h                 │           │ line with bash    
                   │        │                   │           │ login shell       
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 bash_nonlogin_she │ script │ generic.local.bas │ tutorials │ customize shebang 
 bang              │        │ h                 │           │ line with default 
                   │        │                   │           │ bash (nonlogin)   
                   │        │                   │           │ shell             
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 create_burst_buff │ script │ generic.local.(sh │ jobs      │ Create a burst    
 er_executors      │        │ |bash)            │           │ buffer for        
                   │        │                   │           │ multiple          
                   │        │                   │           │ executors         
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 _bin_sh_shell     │ script │ generic.local.sh  │ tutorials │ /bin/sh shell     
                   │        │                   │           │ example           
───────────────────┼────────┼───────────────────┼───────────┼───────────────────
 _bin_bash_shell   │ script │ generic.local.bas │ tutorials │ /bin/bash shell   
...

Finally, we can combine multiple filter fields separated by comma, in the next example we can query all buildspecs with tags=tutorials, executor=generic.local.sh, and type=script

buildtest buildspec find --format name,tags,executor,type --filter tags=tutorials,executor=generic.local.sh,type=script
$ buildtest buildspec find --format name,tags,executor,type --filter tags=tutorials,executor=generic.local.sh,type=script
Buildspec Cache: /tmp/tmpxadaezwi/var/buildspecs/cache.json 
 name               ┃ tags      ┃ executor         ┃ type   
━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━
 _bin_sh_shell      │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 sh_shell           │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 shell_options      │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 foo_bar            │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 timelimit_min_max  │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 timelimit_min      │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 timelimit_max      │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 timelimit_min_fail │ tutorials │ generic.local.sh │ script 
────────────────────┼───────────┼──────────────────┼────────
 timelimit_max_fail │ tutorials │ generic.local.sh │ script

We can filter output of buildspec cache by buildspec using --filter buildspec=<path> which expects a path to buildspec file. The buildspec must be in the cache and file path must exist in order to fetch the result. The path can be absolute or relative path.

In this next example, we will filter cache by file tutorials/test_status/pass_returncode.yml and use --format name,buildspec to format columns. The --format buildspec will show full path to buildspec and name refers to name of test. For more details on –format see Format buildspec cache.

buildtest buildspec find --filter buildspec=tutorials/test_status/pass_returncode.yml --format name,buildspec
$ buildtest buildspec find --filter buildspec=tutorials/test_status/pass_returncode.yml --format name,buildspec
          Buildspec Cache: /tmp/tmpxadaezwi/var/buildspecs/cache.json           
 name                     ┃ buildspec                                           
━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 exit1_fail               │ /home/docs/checkouts/readthedocs.org/user_builds/bu 
                          │ ildtest/checkouts/stable/tutorials/test_status/pass 
                          │ _returncode.yml                                     
──────────────────────────┼─────────────────────────────────────────────────────
 exit1_pass               │ /home/docs/checkouts/readthedocs.org/user_builds/bu 
                          │ ildtest/checkouts/stable/tutorials/test_status/pass 
                          │ _returncode.yml                                     
──────────────────────────┼─────────────────────────────────────────────────────
 returncode_list_mismatch │ /home/docs/checkouts/readthedocs.org/user_builds/bu 
                          │ ildtest/checkouts/stable/tutorials/test_status/pass 
                          │ _returncode.yml                                     
──────────────────────────┼─────────────────────────────────────────────────────
 returncode_int_match     │ /home/docs/checkouts/readthedocs.org/user_builds/bu 
                          │ ildtest/checkouts/stable/tutorials/test_status/pass 
                          │ _returncode.yml

Format buildspec cache

We have seen how one can filter buildspecs, but we can also configure which columns to display in the output of buildtest buildspec find. By default, we show a pre-selected format fields in the output, however there are more format fields available that can be configured at the command line.

The format fields are specified in comma separated format such as buildtest buildspec find --format <field1>,<field2>,.... You can see a list of all format fields by --helpformat option as shown below

buildtest buildspec find --helpformat
$ buildtest buildspec find --helpformat
              Format Field Description               
┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Field       ┃ Description                         ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ buildspec   │ Display name of buildspec file      │
├─────────────┼─────────────────────────────────────┤
│ description │ Show description of test            │
├─────────────┼─────────────────────────────────────┤
│ executor    │ Display 'executor' property in test │
├─────────────┼─────────────────────────────────────┤
│ name        │ Display name of test                │
├─────────────┼─────────────────────────────────────┤
│ tags        │ Display 'tag' property in test      │
├─────────────┼─────────────────────────────────────┤
│ type        │ Display 'type' property in test     │
└─────────────┴─────────────────────────────────────┘

In the next example, we utilize --format field to show how format fields affect table columns. buildtest will display the table in order of format fields specified in command line.

buildtest buildspec find --format name,description,buildspec
$ buildtest buildspec find --format name,description,buildspec
          Buildspec Cache: /tmp/tmpxadaezwi/var/buildspecs/cache.json           
 name                     ┃ description              ┃ buildspec                
━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━
 bash_login_shebang       │ customize shebang line   │ /home/docs/checkouts/rea 
                          │ with bash login shell    │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/shebang.ym 
                          │                          │ l                        
──────────────────────────┼──────────────────────────┼──────────────────────────
 bash_nonlogin_shebang    │ customize shebang line   │ /home/docs/checkouts/rea 
                          │ with default bash        │ dthedocs.org/user_builds 
                          │ (nonlogin) shell         │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/shebang.ym 
                          │                          │ l                        
──────────────────────────┼──────────────────────────┼──────────────────────────
 create_burst_buffer_exec │ Create a burst buffer    │ /home/docs/checkouts/rea 
 utors                    │ for multiple executors   │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/burstbuffe 
                          │                          │ r_datawarp_executors.yml 
──────────────────────────┼──────────────────────────┼──────────────────────────
 _bin_sh_shell            │ /bin/sh shell example    │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/shell_exam 
                          │                          │ ples.yml                 
──────────────────────────┼──────────────────────────┼──────────────────────────
 _bin_bash_shell          │ /bin/bash shell example  │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/shell_exam 
                          │                          │ ples.yml                 
──────────────────────────┼──────────────────────────┼──────────────────────────
 bash_shell               │ bash shell example       │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/shell_exam 
                          │                          │ ples.yml                 
──────────────────────────┼──────────────────────────┼──────────────────────────
 sh_shell                 │ sh shell example         │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/shell_exam 
                          │                          │ ples.yml                 
──────────────────────────┼──────────────────────────┼──────────────────────────
 shell_options            │ shell options            │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/shell_exam 
                          │                          │ ples.yml                 
──────────────────────────┼──────────────────────────┼──────────────────────────
 skip_all_tests           │ All test in this         │ /home/docs/checkouts/rea 
                          │ buildspec are skipped    │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/skip_build 
                          │                          │ spec.yml                 
──────────────────────────┼──────────────────────────┼──────────────────────────
 this_test_is_also_skippe │ This test is also        │ /home/docs/checkouts/rea 
 d                        │ skipped even if skip is  │ dthedocs.org/user_builds 
                          │ defined in test          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/skip_build 
                          │                          │ spec.yml                 
──────────────────────────┼──────────────────────────┼──────────────────────────
 python_hello             │ Hello World python       │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/python-hel 
                          │                          │ lo.yml                   
──────────────────────────┼──────────────────────────┼──────────────────────────
 foo_bar                  │ prints variable $FOO     │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/maintainer 
                          │                          │ s_example.yml            
──────────────────────────┼──────────────────────────┼──────────────────────────
 csh_shell                │ csh shell example        │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/csh_shell_ 
                          │                          │ examples.yml             
──────────────────────────┼──────────────────────────┼──────────────────────────
 skip                     │ This test is skipped     │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/skip_tests 
                          │                          │ .yml                     
──────────────────────────┼──────────────────────────┼──────────────────────────
 unskipped                │ This test is not skipped │ /home/docs/checkouts/rea 
                          │                          │ dthedocs.org/user_builds 
                          │                          │ /buildtest/checkouts/sta 
                          │                          │ ble/tutorials/skip_tests 
                          │                          │ .yml

Querying buildspec tags

If you want to retrieve all unique tags from all buildspecs you can run buildtest buildspec find --tags. This can be useful if you want to know available tags in your buildspec cache.

buildtest buildspec find --tags
$ buildtest buildspec find --tags
  List of Tags   
┏━━━━━━━━━━━━━━━┓
┃ Tags          ┃
┡━━━━━━━━━━━━━━━┩
│ network       │
│ jobs          │
│ python        │
│ storage       │
│ tutorials     │
│ containers    │
│ configuration │
│ lsf           │
│ pass          │
│ system        │
│ fail          │
│ singularity   │
│ ping          │
│ cobalt        │
│ filesystem    │
└───────────────┘

In addition, buildtest can group tests by tags via buildtest buildspec find --group-by-tags which can be useful if you want to know which tests get executed when running buildtest build --tags. The output is grouped by tag names, followed by name of test and description.

buildtest buildspec find --group-by-tags
$ buildtest buildspec find --group-by-tags
                                 Tests by Tags                                  
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Tags      ┃ Name                      ┃ Description                          ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ tutorials │ bash_login_shebang        │ customize shebang line with bash     │
│           │                           │ login shell                          │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ bash_nonlogin_shebang     │ customize shebang line with default  │
│           │                           │ bash (nonlogin) shell                │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ _bin_sh_shell             │ /bin/sh shell example                │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ _bin_bash_shell           │ /bin/bash shell example              │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ bash_shell                │ bash shell example                   │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ sh_shell                  │ sh shell example                     │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ shell_options             │ shell options                        │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ skip_all_tests            │ All test in this buildspec are       │
│           │                           │ skipped                              │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ this_test_is_also_skipped │ This test is also skipped even if    │
│           │                           │ skip is defined in test              │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ foo_bar                   │ prints variable $FOO                 │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ csh_shell                 │ csh shell example                    │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ skip                      │ This test is skipped                 │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ unskipped                 │ This test is not skipped             │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ sleep                     │ sleep 2 seconds                      │
├───────────┼───────────────────────────┼──────────────────────────────────────┤
│ tutorials │ add_numbers               │ Add X+Y                              │
└───────────┴───────────────────────────┴──────────────────────────────────────┘
...

Querying buildspec executor

If you want to know all executors in your buildspec cache use the buildtest buildspec find --executors command. This can be useful when you want to build by executors (buildtest build --executor).

buildtest buildspec find --executors
$ buildtest buildspec find --executors
     List of Executors     
┏━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Executors               ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ generic.local.bash      │
│ generic.local.csh       │
│ generic.local.(bash|sh) │
│ generic.local.(sh|bash) │
│ generic.local.sh        │
└─────────────────────────┘

Similar to --group-by-tags, buildtest has an option to group tests by executor using --group-by-executor option. This will show tests grouped by executor, name of test and test description. Shown below is an example output.

buildtest buildspec find --group-by-executor
$ buildtest buildspec find --group-by-executor
                               Tests by Executors                               
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Executors          ┃ Name                      ┃ Description                 ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ generic.local.bash │ bash_login_shebang        │ customize shebang line with │
│                    │                           │ bash login shell            │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ bash_nonlogin_shebang     │ customize shebang line with │
│                    │                           │ default bash (nonlogin)     │
│                    │                           │ shell                       │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ _bin_bash_shell           │ /bin/bash shell example     │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ bash_shell                │ bash shell example          │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ skip_all_tests            │ All test in this buildspec  │
│                    │                           │ are skipped                 │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ this_test_is_also_skipped │ This test is also skipped   │
│                    │                           │ even if skip is defined in  │
│                    │                           │ test                        │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ python_hello              │ Hello World python          │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ skip                      │ This test is skipped        │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ unskipped                 │ This test is not skipped    │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ sleep                     │ sleep 2 seconds             │
├────────────────────┼───────────────────────────┼─────────────────────────────┤
│ generic.local.bash │ add_numbers               │ Add X+Y                     │
...

Terse Output

You can use the --terse option to print output of buildtest buildspec find in terse format that can be useful if you want to parse content of file. In example below, we will print output of tags in terse format, the first entry tags is the header followed by list of unique tags. The --no-header option can be used to disable printing of header title.

buildtest buildspec find -t --terse
$ buildtest buildspec find -t --terse
tag
network
jobs
python
storage
tutorials
containers
configuration
lsf
pass
system
fail
singularity
ping
cobalt
filesystem

You can also use --count with terse option, note that heading is not counted as an element, the –count will only limit number of entries reported from the buildspec cache. Shown below we retrieve 5 test results in terse mode and disable heading via -n option.

buildtest buildspec find --terse -n --count=5
$ buildtest buildspec find --terse -n --count=5
bash_login_shebang|script|generic.local.bash|tutorials|customize shebang line with bash login shell
bash_nonlogin_shebang|script|generic.local.bash|tutorials|customize shebang line with default bash (nonlogin) shell
create_burst_buffer_executors|script|generic.local.(sh|bash)|jobs|Create a burst buffer for multiple executors
_bin_sh_shell|script|generic.local.sh|tutorials|/bin/sh shell example
_bin_bash_shell|script|generic.local.bash|tutorials|/bin/bash shell example

Invalid Buildspecs - buildtest buildspec find invalid

buildtest will store invalid buildspecs in the cache file which can be retrieved using buildtest buildspec find invalid. buildtest will attempt to parse each buildspec and store error message for every buildspec. If you run without any options it will report a list of invalid buildspecs as shown below

buildtest buildspec find invalid
$ buildtest buildspec find invalid
                               Invalid Buildspecs                               
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Buildspec                             ┃ Exception                            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'buildtest.exceptions.InvalidBuildsp │
│ e/tutorials/invalid_buildspec_section │ ecSchemaType'>                       │
│ .yml                                  │                                      │
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'jsonschema.exceptions.ValidationErr │
│ e/tutorials/invalid_tags.yml          │ or'>                                 │
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'buildtest.exceptions.InvalidBuildsp │
│ e/tutorials/invalid_executor.yml      │ ecExecutor'>                         │
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'jsonschema.exceptions.ValidationErr │
│ e/tutorials/test_status/file_exists_e │ or'>                                 │
│ xception.yml                          │                                      │
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'jsonschema.exceptions.ValidationErr │
│ e/tutorials/metrics/invalid_metrics.y │ or'>                                 │
│ ml                                    │                                      │
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'jsonschema.exceptions.ValidationErr │
│ e/tutorials/metrics/missing_required_ │ or'>                                 │
│ in_metrics.yml                        │                                      │
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'jsonschema.exceptions.ValidationErr │
│ e/tutorials/metrics/invalid_metric_na │ or'>                                 │
│ me.yml                                │                                      │
│ /home/docs/checkouts/readthedocs.org/ │ <class                               │
│ user_builds/buildtest/checkouts/stabl │ 'buildtest.exceptions.InvalidBuildsp │
│ e/general_tests/sched/pbs/hostname.ym │ ecExecutor'>                         │
│ l                                     │                                      │
└───────────────────────────────────────┴──────────────────────────────────────┘

If you want to see error messages for each buildspec you can pass the -e or --error option which will display output of each buildspec followed by error message.

buildtest buildspec find -e
$ buildtest buildspec find invalid -e
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '"[Schema type must be one of the following: [\'script\', \'compiler\', \'spack\']. ]: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials/invalid_buildspec_section.yml"',
│   'exception': "<class 'buildtest.exceptions.InvalidBuildspecSchemaType'>"
}
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '<ValidationError: "[\'network\', \'network\'] is not valid under any of the given schemas">',
│   'exception': "<class 'jsonschema.exceptions.ValidationError'>"
}
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '"[/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials/invalid_executor.yml]: Unable to find executor: badexecutor in [\'generic.local.bash\', \'generic.local.sh\', \'generic.local.csh\']"',
│   'exception': "<class 'buildtest.exceptions.InvalidBuildspecExecutor'>"
}
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '<ValidationError: "1 is not of type \'string\'">',
│   'exception': "<class 'jsonschema.exceptions.ValidationError'>"
}
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '<ValidationError: "{\'type\': \'str\', \'file_regex\': {\'file\': \'file.txt\', \'exp\': \'BAR\'}, \'regex\': {\'stream\': \'stdout\', \'exp\': \'BAR\'}} is valid under each of {\'required\': [\'file_regex\']}, {\'required\': [\'regex\']}">',
│   'exception': "<class 'jsonschema.exceptions.ValidationError'>"
}
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '<ValidationError: "{\'type\': \'str\'} is not valid under any of the given schemas">',
│   'exception': "<class 'jsonschema.exceptions.ValidationError'>"
}
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '<ValidationError: "\'(foo-bar\' does not match \'^[A-Za-z0-9_.-]+$\'">',
│   'exception': "<class 'jsonschema.exceptions.ValidationError'>"
}
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
{
│   'msg': '"[/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/general_tests/sched/pbs/hostname.yml]: Unable to find executor: generic.pbs.workq in [\'generic.local.bash\', \'generic.local.sh\', \'generic.local.csh\']"',
│   'exception': "<class 'buildtest.exceptions.InvalidBuildspecExecutor'>"
}

Query Maintainers (buildtest buildspec maintainers)

buildtest keeps track of maintainers (i.e authors) for a given buildspec provided that you specify the maintainers property. This is stored in the buildspec cache which can be used to query some interesting details.

Shown below is the help for buildtest buildspec maintainers --help

buildtest buildspec maintainers --help
$ buildtest buildspec maintainers --help
usage: buildtest [options] [COMMANDS] buildspec maintainers
       [-h] [--row-count] [--terse] [-n] [-b] {find} ...

positional arguments:
  {find}
    find           Find buildspecs based on maintainer name

optional arguments:
  -h, --help       show this help message and exit
  --row-count      Display number of rows from query shown in table
  --terse          Print output in machine readable format
  -n, --no-header  Do not print header columns in terse output (--terse)
  -b, --breakdown  Breakdown of buildspecs by maintainers

If you want to see a listing of all maintainers you can run the following

buildtest buildspec maintainers
$ buildtest buildspec maintainers
┏━━━━━━━━━━━━━━━━━━┓
┃ Maintainers      ┃
┡━━━━━━━━━━━━━━━━━━┩
│ @johndoe         │
│ @bobsmith        │
│ @shahzebsiddiqui │
└──────────────────┘

If you prefer a machine readable format, then you can use --terse and --no-header.

buildtest buildspec maintainers --terse --no-header
$ buildtest buildspec maintainers --terse --no-header
@johndoe
@bobsmith
@shahzebsiddiqui

If you want to see a breakdown of all buildspecs by maintainers you can use –breakdown which will display the following information

buildtest buildspec maintainers --breakdown
$ buildtest buildspec maintainers --breakdown
                     Breakdown of buildspecs by maintainers                     
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Maintainers      ┃ Buildspec                                                 ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ @johndoe         │ /home/docs/checkouts/readthedocs.org/user_builds/buildtes │
│                  │ t/checkouts/stable/tutorials/maintainers_example.yml      │
├──────────────────┼───────────────────────────────────────────────────────────┤
│ @bobsmith        │ /home/docs/checkouts/readthedocs.org/user_builds/buildtes │
│                  │ t/checkouts/stable/tutorials/maintainers_example.yml      │
├──────────────────┼───────────────────────────────────────────────────────────┤
│ @shahzebsiddiqui │ /home/docs/checkouts/readthedocs.org/user_builds/buildtes │
│                  │ t/checkouts/stable/tutorials/hello_world.yml:/home/docs/c │
│                  │ heckouts/readthedocs.org/user_builds/buildtest/checkouts/ │
│                  │ stable/general_tests/configuration/ulimits.yml            │
└──────────────────┴───────────────────────────────────────────────────────────┘

The buildtest buildspec maintainers find command can be used to report buildspec given a maintainer name which works similar to –breakdown but doesn’t report information for all maintainers. Shown below, we query all buildspecs by maintainer @shahzebsiddiqui

buildtest buildspec maintainers find @shahzebsiddiqui
$ buildtest buildspec maintainers find @shahzebsiddiqui
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials/hello_world.yml
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/general_tests/configuration/ulimits.yml

Cache Summary - buildtest buildspec summary

The buildtest buildspec summary command can be used to provide a summary of the buildspec cache. This command can be used assuming your cache is built via buildtest buildspec find. Shown below is a summary of the cache file.

buildtest buildspec summary
$ buildtest buildspec summary
╭──────────────────────────────────────────────────────────────────────────────╮
│                                                                              │
│     Reading Buildspec Cache File:  /tmp/tmpxadaezwi/var/buildspecs/cache.jso │
│     Total Valid Buildspecs:        72                                        │
│     Total Invalid Buildspecs:      8                                         │
│     Total Unique Tags:             16                                        │
│     Total Maintainers:             3                                         │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
      Tag Breakdown           Executor Breakdown        Maintainers Breakdown   
┏━━━━━━━━━━━┳━━━━━━━━━━━━┓┏━━━━━━━━━━━━┳━━━━━━━━━━━━┓┏━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃           ┃ total      ┃┃            ┃ total      ┃┃ maintainer ┃ total      ┃
┃ tag       ┃ tests      ┃┃ executor   ┃ tests      ┃┃ s          ┃ buildspecs ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━┩┡━━━━━━━━━━━━╇━━━━━━━━━━━━┩┡━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ tutorials │ 38         ││ generic.lo │ 122        ││ @johndoe   │ 1          │
│ jobs      │ 1          ││ cal.bash   │            ││ @bobsmith  │ 1          │
│ python    │ 2          ││ generic.lo │ 1          ││ @shahzebsi │ 2          │
│ network   │ 2          ││ cal.(sh|ba │            ││ ddiqui     │            │
│ ping      │ 1          ││ sh)        │            │└────────────┴────────────┘
│ system    │ 11         ││ generic.lo │ 20         │                           
│ fail      │ 2          ││ cal.sh     │            │                           
│ pass      │ 2          ││ generic.lo │ 3          │                           
│ container │ 8          ││ cal.csh    │            │                           
│ s         │            ││ generic.lo │ 4          │                           
│ singulari │ 8          ││ cal.(bash| │            │                           
                               Invalid Buildspecs                               
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Buildspecs                                                                   ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/ │
│ tutorials/invalid_buildspec_section.yml                                      │
├──────────────────────────────────────────────────────────────────────────────┤
│ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/ │
│ tutorials/invalid_tags.yml                                                   │
                          Test Breakdown by buildspec                           
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Tests                             ┃ Total ┃ Buildspec                        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ bash_login_shebang                │ 2     │ /home/docs/checkouts/readthedocs │
│ bash_nonlogin_shebang             │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/shebang.ym │
│                                   │       │ l                                │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ create_burst_buffer_executors     │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/burstbuffe │
│                                   │       │ r_datawarp_executors.yml         │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ _bin_sh_shell                     │ 5     │ /home/docs/checkouts/readthedocs │
│ _bin_bash_shell                   │       │ .org/user_builds/buildtest/check │
│ bash_shell                        │       │ outs/stable/tutorials/shell_exam │
│ sh_shell                          │       │ ples.yml                         │
│ shell_options                     │       │                                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ skip_all_tests                    │ 2     │ /home/docs/checkouts/readthedocs │
│ this_test_is_also_skipped         │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/skip_build │
│                                   │       │ spec.yml                         │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ python_hello                      │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/python-hel │
│                                   │       │ lo.yml                           │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ foo_bar                           │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/maintainer │
│                                   │       │ s_example.yml                    │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ csh_shell                         │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/csh_shell_ │
│                                   │       │ examples.yml                     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ skip                              │ 2     │ /home/docs/checkouts/readthedocs │
│ unskipped                         │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/skip_tests │
│                                   │       │ .yml                             │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ sleep                             │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/sleep.yml  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ add_numbers                       │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/add_number │
│                                   │       │ s.yml                            │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ circle_area                       │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/python-she │
│                                   │       │ ll.yml                           │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ bash_env_variables                │ 3     │ /home/docs/checkouts/readthedocs │
│ csh_env_declaration               │       │ .org/user_builds/buildtest/check │
│ tcsh_env_declaration              │       │ outs/stable/tutorials/environmen │
│                                   │       │ t.yml                            │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ hello_world                       │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/hello_worl │
│                                   │       │ d.yml                            │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ string_tag                        │ 2     │ /home/docs/checkouts/readthedocs │
│ list_of_strings_tags              │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/tags_examp │
│                                   │       │ le.yml                           │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ variables_bash                    │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/vars.yml   │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ summary_example                   │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/summary_ex │
│                                   │       │ ample.yml                        │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ gcc_version                       │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/gcc_versio │
│                                   │       │ n.yml                            │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ container_commands_ubuntu         │ 2     │ /home/docs/checkouts/readthedocs │
│ container_options                 │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/containers │
│                                   │       │ /run_commands.yml                │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ hello_world_container_no_commands │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/containers │
│                                   │       │ /hello_world.yml                 │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ bind_mount_in_container           │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/containers │
│                                   │       │ /bind_mounts.yml                 │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ run_script_in_container           │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/containers │
│                                   │       │ /run_script.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ test1                             │ 3     │ /home/docs/checkouts/readthedocs │
│ test2                             │       │ .org/user_builds/buildtest/check │
│ test3                             │       │ outs/stable/tutorials/job_depend │
│                                   │       │ ency/ex2.yml                     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ pass_test                         │ 4     │ /home/docs/checkouts/readthedocs │
│ fail_test                         │       │ .org/user_builds/buildtest/check │
│ pass_and_fail_test                │       │ outs/stable/tutorials/job_depend │
│ final_test                        │       │ ency/ex3.yml                     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ runtime_test                      │ 3     │ /home/docs/checkouts/readthedocs │
│ runtime_test_pass                 │       │ .org/user_builds/buildtest/check │
│ runtime_test_fail                 │       │ outs/stable/tutorials/job_depend │
│                                   │       │ ency/ex4.yml                     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ jobA                              │ 3     │ /home/docs/checkouts/readthedocs │
│ jobB                              │       │ .org/user_builds/buildtest/check │
│ jobC                              │       │ outs/stable/tutorials/job_depend │
│                                   │       │ ency/ex1.yml                     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ status_regex_stdout_pass          │ 4     │ /home/docs/checkouts/readthedocs │
│ status_regex_stdout_fail          │       │ .org/user_builds/buildtest/check │
│ status_regex_stderr_pass          │       │ outs/stable/tutorials/test_statu │
│ status_regex_stderr_fail          │       │ s/status_regex.yml               │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ status_logical_and                │ 2     │ /home/docs/checkouts/readthedocs │
│ status_logical_or                 │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/mode.yml                       │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ file_traverse_limit               │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/file_count_file_traverse_limit │
│                                   │       │ .yml                             │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ regex_on_multiple_files           │ 3     │ /home/docs/checkouts/readthedocs │
│ regex_on_directory_not_supported  │       │ .org/user_builds/buildtest/check │
│ file_expansion_supported          │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/regex_on_filename.yml          │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ always_pass                       │ 4     │ /home/docs/checkouts/readthedocs │
│ always_fail                       │       │ .org/user_builds/buildtest/check │
│ test_fail_returncode_match        │       │ outs/stable/tutorials/test_statu │
│ test_pass_returncode_mismatch     │       │ s/explicit_state.yml             │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ file_exists_pass                  │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/file_exists_with_number.yml    │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ exit1_fail                        │ 4     │ /home/docs/checkouts/readthedocs │
│ exit1_pass                        │       │ .org/user_builds/buildtest/check │
│ returncode_list_mismatch          │       │ outs/stable/tutorials/test_statu │
│ returncode_int_match              │       │ s/pass_returncode.yml            │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ timelimit_min_max                 │ 5     │ /home/docs/checkouts/readthedocs │
│ timelimit_min                     │       │ .org/user_builds/buildtest/check │
│ timelimit_max                     │       │ outs/stable/tutorials/test_statu │
│ timelimit_min_fail                │       │ s/runtime_status_test.yml        │
│ timelimit_max_fail                │       │                                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ status_exists                     │ 2     │ /home/docs/checkouts/readthedocs │
│ status_exists_failure             │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/exists.yml                     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ symlink_test                      │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/is_symlink.yml                 │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ file_count_by_expression          │ 2     │ /home/docs/checkouts/readthedocs │
│ file_extension_and_filepattern    │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/file_count_pattern.yml         │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ file_and_dir_checks               │ 2     │ /home/docs/checkouts/readthedocs │
│ combined_file_and_dir_checks      │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/file_and_dir_check.yml         │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ file_count_on_directory           │ 2     │ /home/docs/checkouts/readthedocs │
│ file_count_by_extension           │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/file_count.yml                 │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ file_count_by_filetype            │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/test_statu │
│                                   │       │ s/file_count_filetype.yml        │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ assert_lt_example                 │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_lt.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ assert_range_ex                   │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_range.yml               │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ assert_gt_example                 │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_gt.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ assert_eq_example                 │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_eq.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ assert_ne_example                 │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_ne.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ assert_eq_invalid_metric          │ 2     │ /home/docs/checkouts/readthedocs │
│ assert_eq_mismatch                │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_eq_exceptions.yml       │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ stream_test                       │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_ge.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ assert_le_example                 │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/assert_le.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ contains_and_not_contains         │ 2     │ /home/docs/checkouts/readthedocs │
│ assert_contains_fail              │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/perf_check │
│                                   │       │ s/contains.yml                   │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ metric_regex_example              │ 2     │ /home/docs/checkouts/readthedocs │
│ metric_file_regex                 │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/metrics/me │
│                                   │       │ trics_regex.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ metric_file_regex_invalid_file    │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/metrics/me │
│                                   │       │ trics_file_regex_invalid_file.ym │
│                                   │       │ l                                │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ multiple_executors                │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/multi_exec │
│                                   │       │ utors/executor_regex_script.yml  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ executors_vars_env_declaration    │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/multi_exec │
│                                   │       │ utors/executors_var_env_declarat │
│                                   │       │ ion.yml                          │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ status_returncode_by_executors    │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/multi_exec │
│                                   │       │ utors/status_by_executors.yml    │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ executors_sbatch_declaration      │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/tutorials/multi_exec │
│                                   │       │ utors/executor_scheduler.yml     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ build_sif_from_dockerimage        │ 3     │ /home/docs/checkouts/readthedocs │
│ build_sandbox_image               │       │ .org/user_builds/buildtest/check │
│ build_remoteimages                │       │ outs/stable/general_tests/contai │
│                                   │       │ ners/singularity/build.yml       │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ pullImage_dockerhub               │ 3     │ /home/docs/checkouts/readthedocs │
│ pullImage_sylabscloud             │       │ .org/user_builds/buildtest/check │
│ pullImage_shub                    │       │ outs/stable/general_tests/contai │
│                                   │       │ ners/singularity/pull.yml        │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ runImage                          │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/contai │
│                                   │       │ ners/singularity/run.yml         │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ inspect_image                     │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/contai │
│                                   │       │ ners/singularity/inspect.yml     │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ root_disk_usage                   │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/config │
│                                   │       │ uration/disk_usage.yml           │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ systemd_default_target            │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/config │
│                                   │       │ uration/systemd-default-target.y │
│                                   │       │ ml                               │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ kernel_swapusage                  │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/config │
│                                   │       │ uration/kernel_state.yml         │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ ulimit_filelock_unlimited         │ 6     │ /home/docs/checkouts/readthedocs │
│ ulimit_cputime_unlimited          │       │ .org/user_builds/buildtest/check │
│ ulimit_stacksize_unlimited        │       │ outs/stable/general_tests/config │
│ ulimit_vmsize_unlimited           │       │ uration/ulimits.yml              │
│ ulimit_filedescriptor_4096        │       │                                  │
│ ulimit_max_user_process_2048      │       │                                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ qsub_version                      │ 7     │ /home/docs/checkouts/readthedocs │
│ qselect_version                   │       │ .org/user_builds/buildtest/check │
│ cqsub_version                     │       │ outs/stable/general_tests/sched/ │
│ qdel_version                      │       │ cobalt/commands.yml              │
│ qmove_version                     │       │                                  │
│ show_jobs                         │       │                                  │
│ show_queues                       │       │                                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ show_lsf_queues                   │ 3     │ /home/docs/checkouts/readthedocs │
│ show_lsf_queues_formatted         │       │ .org/user_builds/buildtest/check │
│ show_lsf_queues_current_user      │       │ outs/stable/general_tests/sched/ │
│                                   │       │ lsf/bqueues.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ show_host_groups                  │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/sched/ │
│                                   │       │ lsf/bmgroups.yml                 │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ display_lsf_hosts                 │ 3     │ /home/docs/checkouts/readthedocs │
│ display_hosts_format              │       │ .org/user_builds/buildtest/check │
│ bhosts_version                    │       │ outs/stable/general_tests/sched/ │
│                                   │       │ lsf/bhosts.yml                   │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ show_lsf_configuration            │ 4     │ /home/docs/checkouts/readthedocs │
│ show_lsf_models                   │       │ .org/user_builds/buildtest/check │
│ show_lsf_resources                │       │ outs/stable/general_tests/sched/ │
│ lsf_version                       │       │ lsf/lsinfo.yml                   │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ show_lsf_user_groups              │ 1     │ /home/docs/checkouts/readthedocs │
│                                   │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/sched/ │
│                                   │       │ lsf/bugroup.yml                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ nodes_state_down                  │ 9     │ /home/docs/checkouts/readthedocs │
│ nodes_state_reboot                │       │ .org/user_builds/buildtest/check │
│ nodes_state_allocated             │       │ outs/stable/general_tests/sched/ │
│ nodes_state_completing            │       │ slurm/sinfo.yml                  │
│ nodes_state_idle                  │       │                                  │
│ node_down_fail_list_reason        │       │                                  │
│ dead_nodes                        │       │                                  │
│ get_partitions                    │       │                                  │
│ sinfo_version                     │       │                                  │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ slurm_config                      │ 2     │ /home/docs/checkouts/readthedocs │
│ show_partition                    │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/sched/ │
│                                   │       │ slurm/scontrol.yml               │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ current_user_queue                │ 2     │ /home/docs/checkouts/readthedocs │
│ show_all_jobs                     │       │ .org/user_builds/buildtest/check │
│                                   │       │ outs/stable/general_tests/sched/ │
│                                   │       │ slurm/squeue.yml                 │
├───────────────────────────────────┼───────┼──────────────────────────────────┤
│ show_accounts                     │ 4     │ /home/docs/checkouts/readthedocs │
│ show_users                        │       │ .org/user_builds/buildtest/check │
│ show_qos                          │       │ outs/stable/general_tests/sched/ │
│ show_tres                         │       │ slurm/sacctmgr.yml               │
└───────────────────────────────────┴───────┴──────────────────────────────────┘

Validate Buildspecs - buildtest buildspec validate

buildtest can validate buildspecs through the buildtest buildspec validate command which provides analogous options for buildtest build for selecting buildspecs such as -b, -e, -t and -e. This command can be used to validate buildspecs with the JSON Schema which can be useful if you are writing a buildspec and want to validate the buildspec without running the test.

Shown below are the available command options.

buildtest buildspec validate --help
$ buildtest buildspec validate --help
usage: buildtest [options] [COMMANDS] buildspec validate [-h] [-b BUILDSPEC]
                                                         [-x EXCLUDE]
                                                         [-e EXECUTOR]
                                                         [-t TAG]

optional arguments:
  -h, --help            show this help message and exit
  -b BUILDSPEC, --buildspec BUILDSPEC
                        Specify path to buildspec (file, or directory) to
                        validate
  -x EXCLUDE, --exclude EXCLUDE
                        Specify path to buildspec to exclude (file or
                        directory) during validation
  -e EXECUTOR, --executor EXECUTOR
                        Specify buildspecs by executor name to validate
  -t TAG, --tag TAG     Specify buildspecs by tag name to validate

The -b option can be used to specify path to buildspec file or directory to validate buildspecs. If its a directory, buildtest will traverse all directories recursively and find any .yml file extensions and attempt to validate each buildspec. Shown below is an example output of what it may look like

buildtest buildspec validate -b tutorials/vars.yml
$ buildtest buildspec validate -b tutorials/vars.yml
buildspec: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials/vars.yml is valid
All buildspecs passed validation!!!

If buildtest detects an error during validation, the error message will be displayed to screen with a non-zero returncode.

buildtest buildspec validate -b tutorials/invalid_tags.yml
$ buildtest buildspec validate -b tutorials/invalid_tags.yml
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
['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']


1 buildspecs failed to validate

Similarly we can search buildspecs based on tags if you want to validate a group of buildspecs using the -t option. We can append -t option multiple times to search by multiple tag names. In this next example, we will validate all buildspecs for python and pass tags.

buildtest buildspec validate -t python -t pass
$ buildtest buildspec validate -t python -t pass
buildspec: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials/test_status/pass_returncode.yml is valid
buildspec: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials/python-hello.yml is valid
buildspec: /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable/tutorials/python-shell.yml is valid
All buildspecs passed validation!!!

Show buildspec buildtest buildspec show

buildtest can display content of buildspec file given a test name via buildtest buildspec show command which expects a positional argument that is the name of test. This can be quick way to see content of buildspec without remembering the full path to the buildspec.

In this next example, we will instruct buildtest to show content of buildspec for test name python_hello.

buildtest buildspec show python_hello
$ buildtest buildspec show python_hello
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
buildspecs:                                                                     
  python_hello:                                                                 
    type: script                                                                
    description: Hello World python                                             
    executor: generic.local.bash                                                
    tags: python                                                                
    run: python hello.py

You can pass multiple arguments to buildtest buildspec show to show content of each test

buildtest buildspec show python_hello circle_area
$ buildtest buildspec show python_hello circle_area
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
buildspecs:                                                                     
  python_hello:                                                                 
    type: script                                                                
    description: Hello World python                                             
    executor: generic.local.bash                                                
    tags: python                                                                
    run: python hello.py                                                        
                                                                                
                                                                                
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
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)

There is bash completion for this command which will show list of test names available in the cache assuming you have run buildtest buildspec find. If you specify an invalid test name you will get an error followed by list of tests that are available in the cache

buildtest buildspec show python_hello
$ buildtest buildspec show XYZ123!
Unable to find test XYZ123! in cache

You can use --theme option to define the color scheme used for printing content of buildspecs. The available comlor schemes can be found at https://pygments.org/docs/styles/#getting-a-list-of-available-styles. buildtest supports tab completion on the available themes which you can see below

$  buildtest bc show --theme
abap                autumn              default             friendly_grayscale  igor                manni               native              pastie              sas                 stata-dark          vim
algol               borland             dracula             fruity              inkpot              material            one-dark            perldoc             solarized-dark      stata-light         vs
algol_nu            bw                  emacs               gruvbox-dark        lilypond            monokai             paraiso-dark        rainbow_dash        solarized-light     tango               xcode
arduino             colorful            friendly            gruvbox-light       lovelace            murphy              paraiso-light       rrt                 stata               trac                zenburn

Show fail buildspec buildtest buildspec show-fail

buildtest can display content of buildspec file of all failed tests via buildtest buildspec show-fail command. This can be quick way to see content of buildspec file given a failed test name such as buildtest buildspec show-fail exit1_fail.

buildtest buildspec show-fail exit1_fail
$ buildtest buildspec show-fail exit1_fail
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/stable… ─
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

If you run buildtest buildspec show-fail without any argument, then buildtest will show content of all failed tests with corresponding buildspec. buildtest will automatically filter out duplicate buildspec entries where multiple test correspond to same buildspec to avoid printing content of buildspec multiple times.

Editing buildspecs in your preferred editor

buildtest provides an interface to automatically open your buildspecs in editor and validate them after closing file. You are welcome to open your buildspec in your editor (vim, emacs, nano) but you won’t be able to validate the buildspec unless you explicitly run the test or use buildtest buildspec validate to see if your buildspec is valid. buildtest comes with two commands to edit your buildspecs buildtest buildspec edit-test and buildtest buildspec edit-file which we will discuss below.

Editing by Test buildtest buildspec edit-test

The buildtest buildspec edit-test allows one to specify a list of test as positional arguments to edit-test in your preferred editor. buildtest will provide tab completion for this command to show all test available in cache which works similar to buildtest buildspec show command.

For instance, we can see the following test are available as part of command completion

$ buildtest buildspec edit-test
_bin_bash_shell                 download_stream                 nodes_state_down                show_host_groups                string_tag
_bin_sh_shell                   executor_regex_script_schema    nodes_state_idle                show_jobs                       systemd_default_target
add_numbers                     executors_sbatch_declaration    nodes_state_reboot              show_lsf_configuration          tcsh_env_declaration
always_fail                     executors_vars_env_declaration  pullImage_dockerhub             show_lsf_models                 test_fail_returncode_match
always_pass                     exit1_fail                      pullImage_shub                  show_lsf_queues                 test_pass_returncode_mismatch
bash_env_variables              exit1_pass                      pullImage_sylabscloud           show_lsf_queues_current_user    timelimit_max
bash_login_shebang              foo_bar                         python_hello                    show_lsf_queues_formatted       timelimit_max_fail
bash_nonlogin_shebang           gcc_version                     qdel_version                    show_lsf_resources              timelimit_min
bash_shell                      get_partitions                  qmove_version                   show_lsf_user_groups            timelimit_min_fail
bhosts_version                  hello_world                     qselect_version                 show_partition                  timelimit_min_max
build_remoteimages              inspect_image                   qsub_version                    show_qos                        ulimit_cputime_unlimited
build_sandbox_image             jobA                            returncode_int_match            show_queues                     ulimit_filedescriptor_4096
build_sif_from_dockerimage      jobB                            returncode_list_mismatch        show_tres                       ulimit_filelock_unlimited
circle_area                     jobC                            root_disk_usage                 show_users                      ulimit_max_user_process_2048
cqsub_version                   kernel_swapusage                runImage                        sinfo_version                   ulimit_stacksize_unlimited
csh_env_declaration             list_of_strings_tags            run_stream                      skip                            ulimit_vmsize_unlimited
csh_shell                       lsf_version                     selinux_disable                 sleep                           unskipped
current_user_queue              metric_regex_example            sh_shell                        slurm_config                    variables_bash
dead_nodes                      node_down_fail_list_reason      shell_options                   status_regex_fail
display_hosts_format            nodes_state_allocated           show_accounts                   status_regex_pass
display_lsf_hosts               nodes_state_completing          show_all_jobs                   status_returncode_by_executors

Let’s take for instance we want to edit the following test, buildtest will search the buildspec cache and find the buildspec file, open in editor and once changes are written to disk, the next file will be processed until all files are written to disk.

$ buildtest buildspec edit-test sleep _bin_bash_shell add_numbers
Writing file: /Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/sleep.yml
/Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/sleep.yml is valid
Writing file: /Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/shell_examples.yml
/Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/shell_examples.yml is valid
Writing file: /Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/add_numbers.yml
/Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/add_numbers.yml is valid

If you specify an invalid test, then buildtest will ignore the test and report a message and skip to next test as shown below

$ buildtest buildspec edit-test invalid_test sleep
Unable to find test invalid_test in cache
Writing file: /Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/sleep.yml
/Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/sleep.yml is valid

Edit buildspecs buildtest buildspec edit-file

The buildtest buildspec edit-file command can be used to edit buildspec based on filename as pose to testname. This command works similar to buildtest buildspec edit-test where each file is open in editor and validated upon completion. You can use this command to create new buildspec whereas buildtest buildspec edit-test only works on existing buildspecs loaded in cache. You can pass multiple filenames as arguments if you want to edit several files.

$ buildtest buildspec edit-file $BUILDTEST_ROOT/tutorials/sleep.yml
  Writing file: /Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/sleep.yml
  /Users/siddiq90/Documents/GitHubDesktop/buildtest/tutorials/sleep.yml is valid