Skip to content

Commit c40200b

Browse files
authored
Run tests with code coverage (swiftlang#894)
To help identify poorly tested areas of the extension, run the tests with code coverage. Coverage is reported in the terminal as text as well as stored in the `/coverage` directory as HTML. In CI results can be seen in the terminal at the end of the test run. Locally when running tests in the docker containers HTML coverage results will appear in the `/coverage` folder after the run completes.
1 parent 92977c2 commit c40200b

File tree

6 files changed

+872
-9
lines changed

6 files changed

+872
-9
lines changed

.c8rc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"all": true,
3+
"include": [
4+
"out/**"
5+
],
6+
"exclude": [
7+
"**/node_modules/**",
8+
"out/test/"
9+
],
10+
"reporter": [
11+
"text",
12+
"html"
13+
]
14+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
out
22
dist
3+
coverage
34
node_modules
45
default.profraw
56
*.vsix

docker/docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ services:
3434

3535
test:
3636
<<: *common
37-
command: /bin/bash -xcl "mkdir /tmp/code && cp -r ./ /tmp/code/ && cd /tmp/code && npm ci && npm run lint && npm run format && npm run package && ./docker/test.sh"
37+
command: /bin/bash -xcl "./docker/test.sh"
3838

3939
shell:
4040
<<: *common

docker/test.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
(xvfb-run -a npm test; echo $? > exitcode) | grep -Ev "Failed to connect to the bus|GPU stall due to ReadPixels"
1+
set -ex
2+
3+
current_directory=$(pwd)
4+
5+
mkdir /tmp/code
6+
cp -r ./ /tmp/code/
7+
cd /tmp/code
8+
9+
npm ci
10+
npm run lint
11+
npm run format
12+
npm run package
13+
14+
(xvfb-run -a npm run coverage; echo $? > exitcode) | grep -Ev "Failed to connect to the bus|GPU stall due to ReadPixels" && rm -rf "${current_directory}/coverage" && (cp -R ./coverage $current_directory || true)
215
exit $(<exitcode)

0 commit comments

Comments
 (0)