Skip to content

Commit

Permalink
Fix test output during CI.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
eerhardt committed Aug 6, 2018
1 parent 8087a20 commit 8132a96
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
BuildNative;
$(TraversalBuildDependsOn);
DownloadExternalTestFiles;
RunTests;
</TraversalBuildDependsOn>
</PropertyGroup>

Expand Down Expand Up @@ -79,7 +78,7 @@
TreatErrorsAsWarnings="true"/>
</Target>

<Target Name="RunTests" Condition="'$(RunTests)'=='true'">
<Target Name="RunTests">
<MSBuild Projects="test\run-tests.proj"
Targets="RunTests" />
</Target>
Expand Down
4 changes: 3 additions & 1 deletion build/ci/phase-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ phases:
_configuration: Release
${{ insert }}: ${{ parameters.queue }}
steps:
- script: $(_buildScript) -$(_configuration)
displayName: Build
- script: $(_buildScript) -$(_configuration) -runtests
displayName: Build and Test
displayName: Run Tests
- task: PublishTestResults@2
displayName: Publish Test Results
condition: succeededOrFailed()
Expand Down
8 changes: 4 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"defaultValue": ""
},
"RunTests": {
"description": "Run tests after building.",
"valueType": "property",
"description": "MsBuild target that run the tests. Call this after building.",
"valueType": "target",
"values": [],
"defaultValue": ""
},
Expand Down Expand Up @@ -113,9 +113,9 @@
}
},
"runtests": {
"description": "Runs the tests after building.",
"description": "Runs the tests. Call this after building.",
"settings": {
"RunTests": "true"
"RunTests": "default"
}
},
"verbose": {
Expand Down
4 changes: 2 additions & 2 deletions docs/building/windows-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ You can use the Developer Command Prompt, Powershell or work in any regular cmd.
From a (non-admin) Command Prompt window:

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

**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.

### Running tests from the command line

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

### Running tests from Visual Studio
Expand Down
3 changes: 2 additions & 1 deletion docs/project-docs/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ build.cmd -Release -TargetArchitecture:x64

- Building the src and then building and running the tests
```
build.cmd -RunTests
build.cmd
build.cmd -runTests
```

### Building individual projects
Expand Down
1 change: 1 addition & 0 deletions netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def branch = GithubBranchName

def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
steps {
shell("./build.sh -$config")
shell("./build.sh -$config -runtests")
shell("./build.sh -buildPackages")
}
Expand Down

0 comments on commit 8132a96

Please sign in to comment.