diff options
-rw-r--r-- | .github/workflows/source.yml | 2 | ||||
-rwxr-xr-x | .github/workflows/source/test_travis_matrix.sh | 36 | ||||
-rw-r--r-- | .github/workflows/source/travis_matrix.py | 22 | ||||
-rw-r--r-- | .travis.yml | 10 | ||||
-rw-r--r-- | Regression/prepare_file_travis.py | 65 | ||||
-rwxr-xr-x | run_test.sh | 4 |
6 files changed, 113 insertions, 26 deletions
diff --git a/.github/workflows/source.yml b/.github/workflows/source.yml index 4ca0efd9a..b6f2b5d24 100644 --- a/.github/workflows/source.yml +++ b/.github/workflows/source.yml @@ -25,6 +25,8 @@ jobs: run: .github/workflows/source/wrongFileNameInExamples - name: Examples are tested run: .github/workflows/source/inputsNotTested + - name: Check that the test matrix for Travis includes all tests + run: .github/workflows/source/test_travis_matrix.sh - name: Doxygen run: | sudo apt-get install -y --no-install-recommends doxygen diff --git a/.github/workflows/source/test_travis_matrix.sh b/.github/workflows/source/test_travis_matrix.sh new file mode 100755 index 000000000..400970c54 --- /dev/null +++ b/.github/workflows/source/test_travis_matrix.sh @@ -0,0 +1,36 @@ +#! /usr/bin/env sh + +set -e + +cp .github/workflows/source/travis_matrix.py Regression/ +cd Regression/ + +# Put the name of all travis tests into a text file +python prepare_file_travis.py +grep "\[" travis-tests.ini > travis_all_tests.txt + +# Concatenate the names of all elements in Travis matrix into another test file +WARPX_CI_REGULAR_CARTESIAN=TRUE python prepare_file_travis.py +grep "\[" travis-tests.ini > travis_matrix_elements.txt +WARPX_CI_PSATD=TRUE python prepare_file_travis.py +grep "\[" travis-tests.ini >> travis_matrix_elements.txt +WARPX_CI_PYTHON_MAIN=TRUE python prepare_file_travis.py +grep "\[" travis-tests.ini >> travis_matrix_elements.txt +WARPX_CI_SINGLE_PRECISION=TRUE python prepare_file_travis.py +grep "\[" travis-tests.ini >> travis_matrix_elements.txt +WARPX_CI_RZ_OR_NOMPI=TRUE python prepare_file_travis.py +grep "\[" travis-tests.ini >> travis_matrix_elements.txt +WARPX_CI_QED=TRUE python prepare_file_travis.py +grep "\[" travis-tests.ini >> travis_matrix_elements.txt + +# Check that the resulting lists are equal +{ + python travis_matrix.py && + rm travis_all_tests.txt travis_matrix_elements.txt travis_matrix.py && + echo "test passed" && + exit 0 +} || { + rm travis_all_tests.txt travis_matrix_elements.txt travis_matrix.py && + echo "tests failed" && + exit 1 +} diff --git a/.github/workflows/source/travis_matrix.py b/.github/workflows/source/travis_matrix.py new file mode 100644 index 000000000..87c27a8cf --- /dev/null +++ b/.github/workflows/source/travis_matrix.py @@ -0,0 +1,22 @@ +#! /usr/bin/env python + +# Concatenation of tests in each of the 6 elements in Travis matrix +f = open('./travis_matrix_elements.txt') ; matrix_elements = f.readlines() ; f.close() +# All tests read by prepare_travis_tests.py +f = open('./travis_all_tests.txt') ; all_tests = f.readlines() ; f.close() + +# Now let's make sure these two are equal + +# Remove these elements from both lists, as they are are not test names +elements_to_remove = ['[main]\n', '[AMReX]\n', '[source]\n', '[extra-PICSAR]\n'] +for element in elements_to_remove: + for x in range(matrix_elements.count(element)): + matrix_elements.remove(element) + for x in range(all_tests.count(element)): + all_tests.remove(element) + +# Sort lists, and make sure they are equal +matrix_elements.sort() +all_tests.sort() + +assert( matrix_elements == all_tests ) diff --git a/.travis.yml b/.travis.yml index e4aba5ca7..716a487f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,12 @@ cache: pip env: matrix: - - WARPX_TEST_DIM=3 HAS_QED=FALSE - - WARPX_TEST_DIM=RZ HAS_QED=FALSE - - WARPX_TEST_DIM=2 HAS_QED=FALSE - - HAS_QED=TRUE + - WARPX_CI_REGULAR_CARTESIAN=TRUE + - WARPX_CI_PSATD=TRUE + - WARPX_CI_PYTHON_MAIN=TRUE + - WARPX_CI_SINGLE_PRECISION=TRUE + - WARPX_CI_RZ_OR_NOMPI=TRUE + - WARPX_CI_QED=TRUE before_install: - sudo apt-get update diff --git a/Regression/prepare_file_travis.py b/Regression/prepare_file_travis.py index abec6baea..dfaacc77a 100644 --- a/Regression/prepare_file_travis.py +++ b/Regression/prepare_file_travis.py @@ -13,10 +13,15 @@ import re import os # Get relevant environment variables -dim = os.environ.get('WARPX_TEST_DIM', None) -qed = os.environ.get('HAS_QED', None) arch = os.environ.get('WARPX_TEST_ARCH', 'CPU') +ci_regular_cartesian = os.environ.get('WARPX_CI_REGULAR_CARTESIAN') == 'TRUE' +ci_psatd = os.environ.get('WARPX_CI_PSATD') == 'TRUE' +ci_python_main = os.environ.get('WARPX_CI_PYTHON_MAIN') == 'TRUE' +ci_single_precision = os.environ.get('WARPX_CI_SINGLE_PRECISION') == 'TRUE' +ci_rz_or_nompi = os.environ.get('WARPX_CI_RZ_OR_NOMPI') == 'TRUE' +ci_qed = os.environ.get('WARPX_CI_QED') == 'TRUE' + # Find the directory in which the tests should be run current_dir = os.getcwd() test_dir = re.sub('warpx/Regression', '', current_dir ) @@ -68,25 +73,45 @@ test_blocks = [ match[0] for match in re.findall(select_test_regex, text) ] # - Remove the test blocks from `text` (only the selected ones will be added back) text = re.sub( select_test_regex, '', text ) -# Keep tests that have the right dimension -if dim is not None: - print('Selecting tests with dim = %s' %dim) - # Cartesian tests - if dim in ['2', '3']: - test_blocks = [ block for block in test_blocks \ - if ('dim = %s'%dim in block) and not ('USE_RZ' in block) ] - elif dim == 'RZ': - test_blocks = [ block for block in test_blocks if 'USE_RZ' in block ] - else: - raise ValueError('Unkown dimension: %s' %dim) - -# Remove or keep QED tests according to 'qed' variable -if qed is not None: - print('Selecting tests with QED = %s' %qed) - if (qed == "FALSE"): - test_blocks = [ block for block in test_blocks if not 'QED=TRUE' in block ] +def select_tests(blocks, match_string_list, do_test): + """Remove or keep tests from list in WarpX-tests.ini according to do_test variable""" + if do_test not in [True, False]: + raise ValueError("do_test must be True or False") + if (do_test == False): + for match_string in match_string_list: + print('Selecting tests without ' + match_string) + blocks = [ block for block in blocks if not match_string in block ] else: - test_blocks = [ block for block in test_blocks if 'QED=TRUE' in block ] + for match_string in match_string_list: + print('Selecting tests with ' + match_string) + blocks = [ block for block in blocks if match_string in block ] + return blocks + +if ci_regular_cartesian: + test_blocks = select_tests(test_blocks, ['USE_RZ=TRUE'], False) + test_blocks = select_tests(test_blocks, ['USE_PSATD=TRUE'], False) + test_blocks = select_tests(test_blocks, ['PYTHON_MAIN=TRUE'], False) + test_blocks = select_tests(test_blocks, ['PRECISION=FLOAT', 'USE_SINGLE_PRECISION_PARTICLES=TRUE'], False) + test_blocks = select_tests(test_blocks, ['useMPI = 0'], False) + test_blocks = select_tests(test_blocks, ['QED=TRUE'], False) + +if ci_psatd: + test_blocks = select_tests(test_blocks, ['USE_PSATD=TRUE'], True) + +if ci_python_main: + test_blocks = select_tests(test_blocks, ['PYTHON_MAIN=TRUE'], True) + +if ci_single_precision: + test_blocks = select_tests(test_blocks, ['PRECISION=FLOAT', 'USE_SINGLE_PRECISION_PARTICLES=TRUE'], True) + +if ci_rz_or_nompi: + test_blocks = select_tests(test_blocks, ['PYTHON_MAIN=TRUE'], False) + block1 = select_tests(test_blocks, ['USE_RZ=TRUE'], True) + block2 = select_tests(test_blocks, ['useMPI = 0'], True) + test_blocks = block1 + block2 + +if ci_qed: + test_blocks = select_tests(test_blocks, ['QED=TRUE'], True) # - Add the selected test blocks to the text text = text + '\n' + '\n'.join(test_blocks) diff --git a/run_test.sh b/run_test.sh index 39e99e541..344932e54 100755 --- a/run_test.sh +++ b/run_test.sh @@ -16,7 +16,7 @@ # physically correct. # The tests can be influenced by environment variables: -# Use `export WARPX_TEST_DIM=3` or `export WARPX_TEST_DIM=2` in order to +# Use `export WARPX_CI_DIM=3` or `export WARPX_CI_DIM=2` in order to # select only the tests that correspond to this dimension # Use `export WARPX_TEST_ARCH=CPU` or `export WARPX_TEST_ARCH=GPU` in order # to run the tests on CPU or GPU respectively. @@ -49,7 +49,7 @@ cd test_dir # Clone PICSAR and AMReX git clone --branch development https://github.com/AMReX-Codes/amrex.git # Use QED brach for QED tests -if [ "${HAS_QED}" = "TRUE" ]; then +if [ "${WARPX_CI_QED}" = "TRUE" ]; then git clone --branch QED https://bitbucket.org/berkeleylab/picsar.git else git clone --branch master https://bitbucket.org/berkeleylab/picsar.git |