Skip to content

Commit b179cab

Browse files
committed
Add test-ci build target with collected results
1 parent 17b0edb commit b179cab

8 files changed

Lines changed: 55 additions & 14 deletions

File tree

.config/dotnet-tools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
"docfx"
1616
],
1717
"rollForward": false
18+
},
19+
"trx2junit": {
20+
"version": "2.1.0",
21+
"commands": [
22+
"trx2junit"
23+
],
24+
"rollForward": false
1825
}
1926
}
2027
}

.github/workflows/cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ jobs:
9292
with:
9393
github_token: ${{ secrets.GITHUB_TOKEN }}
9494
publish_dir: build/docs/site
95-
destination_dir: docs/${{ steps.get_version.outputs.VERSION }}
95+
destination_dir: archive/${{ steps.get_version.outputs.VERSION }}
9696

9797
- name: Update latest docs symlink
9898
uses: peaceiris/actions-gh-pages@v4
9999
with:
100100
github_token: ${{ secrets.GITHUB_TOKEN }}
101101
publish_dir: build/docs/site
102-
destination_dir: docs/latest
102+
destination_dir: docs

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
git diff --exit-code || (echo "Code is not properly formatted. Please run 'cmake --build build --target format'" && exit 1)
7272
7373
- name: Run tests
74-
run: cmake --build build --target test
74+
run: cmake --build build --target test-ci
7575

7676
- name: Upload test results
7777
uses: actions/upload-artifact@v4
@@ -85,13 +85,13 @@ jobs:
8585
- name: Generate code coverage (Linux only)
8686
if: matrix.os == 'ubuntu-latest'
8787
run: |
88-
dotnet test --configuration Release --collect:"XPlat Code Coverage" --results-directory ./coverage
88+
dotnet test --configuration Release --collect:"XPlat Code Coverage" -f "net9.0" --results-directory OpenLanguage.Test/coverage
8989
9090
- name: Upload coverage to Codecov (Linux only)
9191
if: matrix.os == 'ubuntu-latest'
9292
uses: codecov/codecov-action@v4
9393
with:
94-
directory: ./coverage
94+
directory: OpenLanguage.Test/coverage
9595
fail_ci_if_error: false
9696
verbose: true
9797

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
**/obj/
33
**/bin/
44
**/*.lst
5+
**/TestResults/
6+
**/coverage/
57

68
# CMake build directories
79
build/

CMakeLists.txt

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ set(SOLUTION_FILE "${CMAKE_SOURCE_DIR}/OpenLanguage.sln")
7070
set(PROJECT_DIR "${CMAKE_SOURCE_DIR}/OpenLanguage")
7171
set(GENERATED_DIR "${PROJECT_DIR}/Generated")
7272
set(TEST_PROJECT_DIR "${CMAKE_SOURCE_DIR}/OpenLanguage.Test")
73+
set(TEST_RESULTS_DIR "${TEST_PROJECT_DIR}/TestResults")
74+
set (TEST_RESULTS_TRX_BASENAME "TestResults.trx")
75+
set(TEST_RESULTS_TRX "${TEST_RESULTS_DIR}/${TEST_RESULTS_TRX_BASENAME}")
76+
set(TEST_RESULTS_XML "${TEST_RESULTS_DIR}/TestResults.xml")
7377

7478
file (GLOB_RECURSE PROJECT_LIST "${PROJECT_DIR}/*.csproj")
7579

@@ -174,12 +178,40 @@ add_custom_target(tool_restore
174178
COMMENT "Restoring dotnet tools"
175179
)
176180

181+
add_custom_target(create_test_results_directory
182+
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_RESULTS_DIR}
183+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
184+
COMMENT "Creating TestResults directory"
185+
)
177186

187+
add_custom_target(run_tests
188+
COMMAND dotnet test "${TEST_PROJECT_DIR}/OpenLanguage.Test.csproj"
189+
--results-directory="${TEST_RESULTS_DIR}"
190+
--configuration="Release"
191+
--framework="net9.0"
192+
--logger="trx\;LogFileName=\"${TEST_RESULTS_TRX}\""
193+
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
194+
DEPENDS build create_test_results_directory
195+
COMMENT "Running unit tests. Outputting results to \"${TEST_RESULTS_TRX}\""
196+
)
197+
198+
add_custom_target(convert_test_results
199+
COMMAND dotnet tool run trx2junit "${TEST_RESULTS_TRX}" --output "${TEST_RESULTS_DIR}"
200+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
201+
DEPENDS run_tests tool_restore
202+
COMMENT "Converting test results from TRX to JUnit XML format. Outputting results to \"${TEST_RESULTS_XML}\""
203+
)
178204

179205
# Test target - dependent on build
206+
add_custom_target(test-ci
207+
DEPENDS convert_test_results
208+
)
209+
180210
add_custom_target(test
181-
COMMAND dotnet test --configuration Release
182-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
211+
COMMAND dotnet test "${TEST_PROJECT_DIR}/OpenLanguage.Test.csproj"
212+
--configuration="Release"
213+
--framework="net9.0"
214+
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
183215
DEPENDS build
184216
COMMENT "Running unit tests"
185217
)

OpenLanguage/SpreadsheetML/Formula/FormulaParser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,8 @@ public static Ast.Node Parse(IEnumerable<char>? chars)
8989
{
9090
return FormulaParser.Parse(chars);
9191
}
92-
catch (Exception e)
92+
catch (Exception)
9393
{
94-
Console.Error.WriteLine(
95-
$"Encountered error while trying to parse formula text: \"{e}\""
96-
);
9794
return null;
9895
}
9996
}

OpenLanguage/SpreadsheetML/Formula/Lang/Lex/formula.lex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ QS_RUN [^'\r\n\[\]]+
5151
private int sr_bracket_nesting_level = 0;
5252

5353
// true iff the last significant token was an identifier or a right bracket
54-
// Whitespace and newlines do NOT reset this; all other tokens do.
54+
// Whitespace and newlines do not reset this; all other tokens do.
5555
private bool lastIdOrRbrack = false;
5656

5757
// Tracks whether we are immediately after a leading '=' (ignoring whitespace)

hooks/pre-commit

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ set -e
77

88
echo "Running pre-commit checks..."
99

10+
echo "Preparing CMake build..."
11+
cmake -B build -DCMAKE_BUILD_TYPE=Release
12+
1013
# Run formatter
1114
echo "Formatting code..."
12-
cmake --build . --target format
15+
cmake --build build --target format
1316

1417
# Check if there are any formatting changes
1518
if ! git diff --quiet; then
@@ -19,7 +22,7 @@ fi
1922

2023
# Run tests
2124
echo "Running tests..."
22-
cmake --build . --target test
25+
cmake --build build --target test
2326

2427
echo "Pre-commit checks passed!"
2528
exit 0

0 commit comments

Comments
 (0)