diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 9a1118a..eb1cc91 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -260,6 +260,30 @@ jobs: grep -q "TestRunner.withTextOutput('LoggingLevel', 3)" console.log rm console.log shell: bash + - matlab/run-tests: + select-by-name: $(circleci tests glob 'tests/**/*.m' | circleci tests split | awk -F'[\\\\/.]' '{print $(NF-1) "/*"}') + source-folder: src + startup-options: -logfile console.log + - run: + name: Verify tests ran as filtered by name + command: | + set -e + grep mytest console.log + grep TaggedTest console.log + grep filtertest console.log + rm console.log + shell: bash + - matlab/run-tests: + select-by-name: "filtertest/*" + test-results-junit: test-results/matlab/filterednameresult.xml + source-folder: src + - run: + name: Verify filter by name test results file was created + command: | + set -e + grep -q filtertest test-results/matlab/filterednameresult.xml + ! grep -q mytest test-results/matlab/filterednameresult.xml + shell: bash # Set up for model coverage artifact tests - when: diff --git a/src/commands/run-tests.yml b/src/commands/run-tests.yml index dfd7e88..8518c6c 100644 --- a/src/commands/run-tests.yml +++ b/src/commands/run-tests.yml @@ -14,6 +14,11 @@ parameters: folders using a colon-separated or semicolon-separated list. type: string default: '' + select-by-name: + description: > + Name of the test used to select test suite elements, specified as a list of names separated by spaces. The command filters an existing test suite to include only the test elements that match the specified names. Use the wildcard character (*) to match any number of characters. Use the question mark character (?) to match a single character. + type: string + default: '' select-by-folder: description: > Location of the folder used to select test suite elements, relative to the project root folder. @@ -128,6 +133,7 @@ steps: PARAM_TEST_RESULTS_PDF: <> PARAM_STRICT: <> PARAM_USE_PARALLEL: <> + PARAM_SELECT_BY_NAME: <> PARAM_OUTPUT_DETAIL: <> PARAM_LOGGING_LEVEL: <> PARAM_STARTUP_OPTIONS: <> diff --git a/src/scripts/run-tests.sh b/src/scripts/run-tests.sh index 2cb5698..046077b 100644 --- a/src/scripts/run-tests.sh +++ b/src/scripts/run-tests.sh @@ -60,6 +60,14 @@ if [[ "$os" = CYGWIN* || "$os" = MINGW* || "$os" = MSYS* ]]; then binext=".exe" fi +selectByName=$(eval echo "$PARAM_SELECT_BY_NAME" | awk '{ + for(i=1; i<=NF; i++) { + gsub(/\047/, "\047\047", $i); + printf "\047%s\047%s", $i, (i==NF ? "" : ", "); + } +}') +selectByName="{$selectByName}" + "${tmpdir}/bin/run-matlab-command$binext" "\ addpath('${gendir}/scriptgen');\ testScript = genscript('Test',\ @@ -76,6 +84,7 @@ fi 'PDFTestReport','${PARAM_TEST_RESULTS_PDF}',\ 'Strict',${PARAM_STRICT},\ 'UseParallel',${PARAM_USE_PARALLEL},\ + 'SelectByName', $selectByName,\ 'OutputDetail','${PARAM_OUTPUT_DETAIL}',\ 'LoggingLevel','${PARAM_LOGGING_LEVEL}');\ disp('Running MATLAB script with contents:');\