Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 369b407

Browse files
committed
Merge pull request #2661 from ellismg/run-test-improvements
Make it easier to use run-test.sh outside CI.
2 parents 8b7a0fa + 26cc472 commit 369b407

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Running XUnit tests cross platform
2+
3+
Unlike Windows, where we run tests as part of the build, we have a seperate
4+
explicit testing step on Linux and OSX. Over time, this special step will go
5+
away in favor of a similar "run tests during the build" model.
6+
7+
`run-test.sh` is the shell script used by Jenkins in order to run all the XUnit
8+
tests cross platform. It combines the cross platform CoreCLR and CoreFX builds
9+
together into a test layout and then runs each test project from CoreFX.
10+
11+
In order to run tests, you need to build a bunch of different projects. The
12+
instructions assume you are building for Linux, but are easily modifiable for OSX.
13+
14+
1. Release or debug CoreCLR. In Jenkins we use a release CoreCLR build instead
15+
of debug CoreCLR since it is much faster at actually running XUnit, but debug
16+
will work if you have the time.
17+
18+
From the root of your CoreCLR enlistment on Linux, run `./build.sh Release` in
19+
order to build.
20+
2. A coresponding version of mscorlib.dll, built on Windows but targeting
21+
Linux. This can be produced by running `build.cmd linuxmscorlib Release` from
22+
a CoreCLR enlistment on Windows. Remember that the runtime and mscorlib are
23+
tightly coupled with respect to object sizes and layout so you need to ensure
24+
you have either a release coreclr and release mscorlib or debug coreclr and
25+
debug mscorlib.
26+
3. A Linux build of CoreFX. On Windows, run `build.cmd /p:OSGroup=Linux`. It
27+
is okay to build a Debug version of CoreFX and run it on top of a release
28+
CoreCLR (which is exactly what we do in Jenkins).
29+
4. A Linux build of the native CoreFX components. On Linux, run ./build.sh from
30+
src/Native in your CoreFX enlistment.
31+
32+
After building all the projects, we need to copy the files we built on Windows
33+
over to our Linux machine. The easiest way to do this is to mount a windows
34+
share on linux. For example, I do:
35+
36+
```
37+
# sudo mount.cifs "//MATELL3/D\$" ~/mnt/matell3/d -o user=matell
38+
```
39+
40+
The copy the CoreFX binaries over to your local machine (I have my enlistements
41+
on Linux under ~/git).
42+
43+
```
44+
# rsync -v -r --exclude 'obj' --exclude 'packages' ~/mnt/matell3/d/git/corefx/bin/ ~/git/corefx/bin/
45+
# rsync -v -r ~/mnt/matell3/d/git/coreclr/bin/Product/ ~/git/coreclr/bin/Product/
46+
```
47+
48+
Then, run the tests. run-test.sh defaults to wanting to use Windows tests (for
49+
historical reasons), so we need to pass an explict path to the tests, as well as
50+
a path to the location of CoreCLR and mscorlib.dll.
51+
52+
```
53+
# ./run-test.sh --coreclr-bins ~/git/coreclr/bin/Product/Linux.x64.Release \
54+
--mscorlib-bins ~/git/coreclr/bin/Product/Linux.x64.Release \
55+
--corefx-tests ~/git/corefx/bin/tests/Linux.AnyCPU.Debug
56+
```
57+
58+
run-test.sh should now invoke all the managed tests.

run-test.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,17 @@ runtest()
190190

191191
copy_test_overlay $dirName
192192

193+
pushd $dirName > /dev/null
194+
195+
# Remove the mscorlib native image, since our current test layout build process
196+
# uses a windows runtime and so we include the windows native image for mscorlib
197+
if [ -e mscorlib.ni.dll ]
198+
then
199+
rm mscorlib.ni.dll
200+
fi
201+
193202
# Invoke xunit
194203

195-
pushd $dirName > /dev/null
196204
echo
197205
echo "Running tests in $dirName"
198206
echo "./corerun xunit.console.netcore.exe $testDllName -xml testResults.xml -notrait category=failing -notrait category=OuterLoop -notrait category=$xunitOSCategory"

0 commit comments

Comments
 (0)