forked from kaitai-io/kaitai_struct_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-csharp
executable file
·63 lines (54 loc) · 2.55 KB
/
run-csharp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
. ./config
CSHARP_TEST_FORMATS_DIR=$FORMATS_COMPILED_DIR/csharp
CSHARP_SPEC_DIR=spec/csharp
CSHARP_TEST_OUT_DIR="$TEST_OUT_DIR"/csharp
CSHARP_COMPILE_LOG_XBUILD="$CSHARP_TEST_OUT_DIR/_compile-0.log"
CSHARP_COMPILE_LOG_MCS_FORMATS="$CSHARP_TEST_OUT_DIR/_compile-1.log"
CSHARP_COMPILE_LOG_MCS_SPECS="$CSHARP_TEST_OUT_DIR/_compile-2.log"
CSHARP_COMPILE_LOG_XBUILD2="$CSHARP_TEST_OUT_DIR/_compile-3.log"
rm -rf "$CSHARP_TEST_OUT_DIR"
mkdir -p "$CSHARP_TEST_OUT_DIR"
# Try and build the project first - if there's no compile errors, we can continue straight away
echo "run-csharp: building project"
xbuild "$CSHARP_SPEC_DIR/kaitai_struct_csharp_tests.sln" >"$CSHARP_COMPILE_LOG_XBUILD" || {
# Some formats failed to build - find the failing files and erase them
./travis-fold xbuild cat "$CSHARP_COMPILE_LOG_XBUILD"
echo "run-csharp: some formats failed to compile, checking each file individually"
# Find the invalid files and wipe them - we do this by scanning the error list from the compiler
mcs \
-t:library \
-fullpaths \
-warn:0 \
-r:"$CSHARP_SPEC_DIR/packages/NUnit.3.4.1/lib/net45/nunit.framework.dll" \
"$CSHARP_RUNTIME_DIR/*.cs" \
"$CSHARP_SPEC_DIR/kaitai_struct_csharp_tests/CommonSpec.cs" \
"$CSHARP_TEST_FORMATS_DIR"/*.cs \
2>&1 >"$CSHARP_COMPILE_LOG_MCS_FORMATS" | \
fgrep '(' | cut -d'(' -f1 | xargs -d '\n' truncate -c -s0
./travis-fold mcs_formats cat "$CSHARP_COMPILE_LOG_MCS_FORMATS"
echo "run-csharp: removing tests that are no longer valid"
# Now that the invalid spec classes are gone, we need to remove the matching test cases
mcs \
-t:library \
-fullpaths \
-warn:0 \
-r:"$CSHARP_SPEC_DIR/packages/NUnit.3.4.1/lib/net45/nunit.framework.dll" \
"$CSHARP_RUNTIME_DIR/*.cs" \
"$CSHARP_SPEC_DIR/kaitai_struct_csharp_tests/CommonSpec.cs" \
"$CSHARP_TEST_FORMATS_DIR"/*.cs \
"$CSHARP_SPEC_DIR/kaitai_struct_csharp_tests/tests/*.cs" \
2>&1 >"$CSHARP_COMPILE_LOG_MCS_SPECS" | \
fgrep '(' | cut -d'(' -f1 | xargs -d '\n' truncate -c -s0
# Invalid tests should all be gone - rebuild the project
./travis-fold mcs_specs cat "$CSHARP_COMPILE_LOG_MCS_FORMATS"
echo "run-csharp: rebuilding project"
xbuild "$CSHARP_SPEC_DIR/kaitai_struct_csharp_tests.sln" >"$CSHARP_COMPILE_LOG_XBUILD2"
./travis-fold mcs_formats cat "$CSHARP_COMPILE_LOG_XBUILD2"
}
# Actually run the tests
mkdir -p "$TEST_OUT_DIR/csharp"
mono \
"$CSHARP_SPEC_DIR/packages/NUnit.ConsoleRunner.3.4.1/tools/nunit3-console.exe" \
--result="$TEST_OUT_DIR/csharp/TestResult.xml" \
"$CSHARP_SPEC_DIR/kaitai_struct_csharp_tests/bin/Debug/kaitai_struct_csharp_tests.dll"