Skip to content

Commit 4d98ee3

Browse files
vanditaMWmw-kapilg
andauthored
Add select-by-name and support CircleCI Test Splitting (#76)
* initial * initial * timing1 * timing2 * filename * filename * filename * filename * filename * filename * filename * filename * filename1 * filename * filename * filename * filename * filename * filename * filename2 * filesize * timings * timings * timings * timings2 * try * try * passing new param as char * final draft * filesize * timing 1st run * without selectByName * final draft * removing extra files * changed test-deploy * cell array * cell array * cell array * cell array file name * without feature * without feature * without feature * Cleaning repo * Cleaning repo * fixing lint * fixing lint * updated description * addressing comment * Resolving comments * Added test * Added verification step * Updated verification step * updated test verification * updated test-deploy * updated test_deploy.yml * Trigger pipeline * fix verification as per new scriptgen * escape curly braces * revert escaping curly braces --------- Co-authored-by: Kapil Gupta <[email protected]> Co-authored-by: Kapil Gupta <[email protected]>
1 parent 8043aaf commit 4d98ee3

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

.circleci/test-deploy.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ jobs:
309309
name: Verify tests ran with detailed display level for event details
310310
command: |
311311
set -e
312-
grep -q "TestRunner.withTextOutput('OutputDetail', 3)" console.log
312+
grep -q "('OutputDetail', 3)" console.log
313313
rm console.log
314314
shell: bash
315315
- matlab/run-tests:
@@ -319,9 +319,33 @@ jobs:
319319
name: Verify tests ran with detailed verbosity level for logged diagnostics
320320
command: |
321321
set -e
322-
grep -q "TestRunner.withTextOutput('LoggingLevel', 3)" console.log
322+
grep -q "('LoggingLevel', 3)" console.log
323323
rm console.log
324324
shell: bash
325+
- matlab/run-tests:
326+
select-by-name: $(circleci tests glob 'tests/**/*.m' | circleci tests split | awk -F'[\\\\/.]' '{print $(NF-1) "/*"}')
327+
source-folder: src
328+
startup-options: -logfile console.log
329+
- run:
330+
name: Verify tests ran as filtered by name
331+
command: |
332+
set -e
333+
grep mytest console.log
334+
grep TaggedTest console.log
335+
grep filtertest console.log
336+
rm console.log
337+
shell: bash
338+
- matlab/run-tests:
339+
select-by-name: "filtertest/*"
340+
test-results-junit: test-results/matlab/filterednameresult.xml
341+
source-folder: src
342+
- run:
343+
name: Verify filter by name test results file was created
344+
command: |
345+
set -e
346+
grep -q filtertest test-results/matlab/filterednameresult.xml
347+
! grep -q mytest test-results/matlab/filterednameresult.xml
348+
shell: bash
325349

326350
# Set up for model coverage artifact tests
327351
- when:

src/commands/run-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ parameters:
1414
folders using a colon-separated or semicolon-separated list.
1515
type: string
1616
default: ''
17+
select-by-name:
18+
description: >
19+
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.
20+
type: string
21+
default: ''
1722
select-by-folder:
1823
description: >
1924
Location of the folder used to select test suite elements, relative to the project root folder.
@@ -128,6 +133,7 @@ steps:
128133
PARAM_TEST_RESULTS_PDF: <<parameters.test-results-pdf>>
129134
PARAM_STRICT: <<parameters.strict>>
130135
PARAM_USE_PARALLEL: <<parameters.use-parallel>>
136+
PARAM_SELECT_BY_NAME: <<parameters.select-by-name>>
131137
PARAM_OUTPUT_DETAIL: <<parameters.output-detail>>
132138
PARAM_LOGGING_LEVEL: <<parameters.logging-level>>
133139
PARAM_STARTUP_OPTIONS: <<parameters.startup-options>>

src/scripts/run-tests.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ if [[ "$os" = CYGWIN* || "$os" = MINGW* || "$os" = MSYS* ]]; then
7676
binext=".exe"
7777
fi
7878

79+
selectByName=$(eval echo "$PARAM_SELECT_BY_NAME" | awk '{
80+
for(i=1; i<=NF; i++) {
81+
gsub(/\047/, "\047\047", $i);
82+
printf "\047%s\047%s", $i, (i==NF ? "" : ", ");
83+
}
84+
}')
85+
selectByName="{$selectByName}"
86+
7987
"${tmpdir}/bin/run-matlab-command$binext" "\
8088
addpath('${gendir}/scriptgen');\
8189
testScript = genscript('Test',\
@@ -92,6 +100,7 @@ fi
92100
'PDFTestReport','${PARAM_TEST_RESULTS_PDF}',\
93101
'Strict',${PARAM_STRICT},\
94102
'UseParallel',${PARAM_USE_PARALLEL},\
103+
'SelectByName', $selectByName,\
95104
'OutputDetail','${PARAM_OUTPUT_DETAIL}',\
96105
'LoggingLevel','${PARAM_LOGGING_LEVEL}');\
97106
disp('Running MATLAB script with contents:');\

0 commit comments

Comments
 (0)