Skip to content

Commit f9d3973

Browse files
authored
Fix test output during CI. (#652)
When tests run in CI, we are not displaying the test output to the console. So if a test fails, and for some reason the .trx file isn't parsed correctly, it is impossible to see what test failed and why. The test output isn't being displayed because of microsoft/vstest#1503. To work around the vstest bug, split CI builds into 2 separate MSBuild invocations: one to do the build (which is multi-proc) and another to run the tests (which doesn't need MSBuild node reuse).
1 parent ac4fead commit f9d3973

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

build.proj

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
BuildNative;
3535
$(TraversalBuildDependsOn);
3636
DownloadExternalTestFiles;
37-
RunTests;
3837
</TraversalBuildDependsOn>
3938
</PropertyGroup>
4039

@@ -80,7 +79,7 @@
8079
TreatErrorsAsWarnings="true"/>
8180
</Target>
8281

83-
<Target Name="RunTests" Condition="'$(RunTests)'=='true'">
82+
<Target Name="RunTests">
8483
<MSBuild Projects="test\run-tests.proj"
8584
Targets="RunTests" />
8685
</Target>

build/ci/phase-template.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ phases:
2121
_configuration: Release
2222
${{ insert }}: ${{ parameters.queue }}
2323
steps:
24+
- script: $(_buildScript) -$(_configuration)
25+
displayName: Build
2426
- script: $(_buildScript) -$(_configuration) -runtests
25-
displayName: Build and Test
27+
displayName: Run Tests
2628
- task: PublishTestResults@2
2729
displayName: Publish Test Results
2830
condition: succeededOrFailed()

config.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
"defaultValue": ""
6868
},
6969
"RunTests": {
70-
"description": "Run tests after building.",
71-
"valueType": "property",
70+
"description": "MsBuild target that run the tests. Call this after building.",
71+
"valueType": "target",
7272
"values": [],
7373
"defaultValue": ""
7474
},
@@ -113,9 +113,9 @@
113113
}
114114
},
115115
"runtests": {
116-
"description": "Runs the tests after building.",
116+
"description": "Runs the tests. Call this after building.",
117117
"settings": {
118-
"RunTests": "true"
118+
"RunTests": "default"
119119
}
120120
},
121121
"verbose": {

docs/building/windows-instructions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ You can use the Developer Command Prompt, Powershell or work in any regular cmd.
4646
From a (non-admin) Command Prompt window:
4747

4848
- `build.cmd` - builds the assemblies
49-
- `build.cmd -runTests` - builds the assemblies and runs tests
49+
- `build.cmd -runTests` - called after a normal "build.cmd" will run all tests
5050
- `build.cmd -buildPackages` called after a normal “build.cmd” will create the NuGet packages with the assemblies in “bin"
5151

5252
**Note**: Before working on individual projects or test projects you **must** run `build.cmd` from the root once before beginning that work. It is also a good idea to run `build.cmd` whenever you pull a large set of unknown changes into your branch.
5353

5454
### Running tests from the command line
5555

56-
From the root, use `build.cmd -runTests`.
56+
From the root, run `build.cmd` and then `build.cmd -runTests`.
5757
For more details, or to test an individual project, you can navigate to the test project directory and then use `dotnet test`
5858

5959
### Running tests from Visual Studio

docs/project-docs/developer-guide.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ build.cmd -Release -TargetArchitecture:x64
3232

3333
- Building the src and then building and running the tests
3434
```
35-
build.cmd -RunTests
35+
build.cmd
36+
build.cmd -runTests
3637
```
3738

3839
### Building individual projects

netci.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def branch = GithubBranchName
1616

1717
def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
1818
steps {
19+
shell("./build.sh -$config")
1920
shell("./build.sh -$config -runtests")
2021
shell("./build.sh -buildPackages")
2122
}

0 commit comments

Comments
 (0)