Skip to content

Commit 9f7ed44

Browse files
committed
[Windows] Reduce Windows unit test CI usage
ghstack-source-id: 5186408 ghstack-comment-id: 3300262560 Pull-Request: #14350
1 parent 5ac431f commit 9f7ed44

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

.ci/scripts/unittest-windows.ps1

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
11
param (
2-
[string]$buildMode = "Release"
2+
[string]$buildMode = "Release",
3+
[bool]$runPythonTests = $true,
4+
[bool]$runNativeTests = $true
35
)
46

57
Set-PSDebug -Trace 1
68
$ErrorActionPreference = 'Stop'
79
$PSNativeCommandUseErrorActionPreference = $true
810

11+
if ($runNativeTests) {
912
# Run native unit tests (via ctest)
10-
New-Item -Path "test-build" -ItemType Directory
11-
cd "test-build"
13+
New-Item -Path "test-build" -ItemType Directory
14+
cd "test-build"
1215

13-
cmake .. --preset windows -B . -DEXECUTORCH_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$buildMode
14-
if ($LASTEXITCODE -ne 0) {
15-
Write-Host "CMake configuration was unsuccessful. Exit code: $LASTEXITCODE."
16-
exit $LASTEXITCODE
17-
}
16+
cmake .. --preset windows -B . -DEXECUTORCH_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$buildMode
17+
if ($LASTEXITCODE -ne 0) {
18+
Write-Host "CMake configuration was unsuccessful. Exit code: $LASTEXITCODE."
19+
exit $LASTEXITCODE
20+
}
1821

19-
cmake --build . -j8 --config $buildMode --verbose
20-
if ($LASTEXITCODE -ne 0) {
21-
Write-Host "CMake build was unsuccessful. Exit code: $LASTEXITCODE."
22-
exit $LASTEXITCODE
23-
}
22+
cmake --build . -j8 --config $buildMode --verbose
23+
if ($LASTEXITCODE -ne 0) {
24+
Write-Host "CMake build was unsuccessful. Exit code: $LASTEXITCODE."
25+
exit $LASTEXITCODE
26+
}
2427

25-
ctest -j8 . --build-config $buildMode --output-on-failure -E "method_test|tensor_parser_test"
26-
if ($LASTEXITCODE -ne 0) {
27-
Write-Host "CTest run was unsuccessful. Exit code: $LASTEXITCODE."
28-
exit $LASTEXITCODE
29-
}
28+
ctest -j8 . --build-config $buildMode --output-on-failure -E "method_test|tensor_parser_test"
29+
if ($LASTEXITCODE -ne 0) {
30+
Write-Host "CTest run was unsuccessful. Exit code: $LASTEXITCODE."
31+
exit $LASTEXITCODE
32+
}
3033

31-
cd ..
34+
cd ..
35+
}
3236

37+
if ($runPythonTests) {
3338
# Run pytest
34-
pytest -v -c pytest-windows.ini
35-
if ($LASTEXITCODE -ne 0) {
36-
Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE."
37-
exit $LASTEXITCODE
38-
}
39+
pytest -v -c pytest-windows.ini
40+
if ($LASTEXITCODE -ne 0) {
41+
Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE."
42+
exit $LASTEXITCODE
43+
}
44+
}

.github/workflows/_unittest.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ jobs:
7575
exit \$LASTEXITCODE
7676
}
7777
78-
.ci/scripts/unittest-windows.ps1 -buildMode "${{ inputs.build-mode }}"
78+
# Skip python tests on unittest-release job, which tests the native tests in release mode.
79+
\$runPythonTests = ("${{ inputs.build-mode }}" -eq "Debug")
80+
# Skip native tests in the editable job, as the native tests are unaffected by editable mode.
81+
\$runNativeTests = ("${{ inputs.editable }}" -eq "false")
82+
83+
.ci/scripts/unittest-windows.ps1 -buildMode "${{ inputs.build-mode }}" -runPythonTests \$runPythonTests -runNativeTests \$runNativeTests
7984
if (\$LASTEXITCODE -ne 0) {
8085
Write-Host "Unit tests failed. Exit code: \$LASTEXITCODE."
8186
exit \$LASTEXITCODE

0 commit comments

Comments
 (0)