Skip to content

Commit 982dd65

Browse files
committed
Update file
1 parent e03c52f commit 982dd65

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

AzureDevOps/DistributeTests.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,35 @@
66
# Find all test files (*.m) under ./tests
77
mapfile -t tests < <(find ./tests -type f -name "*.m" | sort)
88

9-
totalAgents=${CI_TOTAL:-1}
10-
agentNumber=${CI_INDEX:-1}
9+
# Use Azure DevOps variables if available, else default to 1
10+
totalAgents=${SYSTEM_TOTALJOBSINPHASE:-1}
11+
agentNumber=${SYSTEM_JOBPOSITIONINPHASE:-1}
1112
testCount=${#tests[@]}
1213

14+
# If not set or zero, default to 1
15+
if [[ -z "$totalAgents" || "$totalAgents" -eq 0 ]]; then
16+
totalAgents=1
17+
fi
18+
if [[ -z "$agentNumber" || "$agentNumber" -eq 0 ]]; then
19+
agentNumber=1
20+
fi
21+
22+
echo "Total agents: $totalAgents"
23+
echo "Agent number: $agentNumber"
24+
echo "Total tests: $testCount"
25+
1326
testsToRun=()
1427

15-
# Slice test files so each agent gets unique tests
28+
# Slice test files so each agent gets unique files (1-based index)
1629
for (( i=agentNumber; i<=testCount; i+=totalAgents )); do
1730
file="${tests[i-1]}"
1831
testsToRun+=("$file")
1932
echo "Added $file"
2033
done
2134

22-
# Format as MATLAB cell array: {'file1','file2'}
23-
joined="{"
24-
for idx in "${!testsToRun[@]}"; do
25-
if [[ $idx -gt 0 ]]; then
26-
joined+=","
27-
fi
28-
joined+="'${testsToRun[$idx]}'"
29-
done
30-
joined+="}"
31-
32-
echo "Final test file list (MATLAB cell array): $joined"
35+
# Join all test files separated by space
36+
testFiles="${testsToRun[*]}"
37+
echo "Test files $testFiles"
3338

3439
# Set as Azure Pipelines variable
35-
echo "##vso[task.setvariable variable=MATLABTestFiles;]$joined"
40+
echo "##vso[task.setvariable variable=pytestfiles;]$testFiles"

0 commit comments

Comments
 (0)