Skip to content

Commit d2bda3e

Browse files
committed
test: add bats tests to test explorer
1 parent 3bd04a5 commit d2bda3e

File tree

7 files changed

+58
-62
lines changed

7 files changed

+58
-62
lines changed

.devcontainer/cpp/devcontainer.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,17 @@
3030
},
3131
"extensions": [
3232
33-
"github.copilot@1.208.0",
34-
"github.vscode-github-actions@0.26.3",
35-
"github.vscode-pull-request-github@0.90.0",
33+
"github.copilot@1.277.0",
34+
"github.vscode-github-actions@0.27.1",
35+
"github.vscode-pull-request-github@0.106.0",
3636
37-
3837
3938
40-
41-
"ms-vscode.cmake-tools@1.18.42",
42-
"ms-vscode.cpptools@1.20.5",
43-
"sonarsource.sonarlint-vscode@4.7.0",
44-
"usernamehw.errorlens@3.20.0"
39+
40+
"ms-vscode.cmake-tools@1.20.53",
41+
"ms-vscode.cpptools@1.23.6",
42+
"sonarsource.sonarlint-vscode@4.17.0",
43+
"usernamehw.errorlens@3.24.0"
4544
]
4645
}
4746
}

.vscode/tasks.json

Lines changed: 0 additions & 40 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
3+
include(CPM)
4+
5+
project(devcontainer-test "NONE")
6+
7+
CPMAddPackage("gh:neonsoftware/cmake-bats#05e53f68976fcee935a40643b30f31e250bc5a9c")
8+
9+
enable_testing()
10+
bats_discover_tests("${CMAKE_CURRENT_SOURCE_DIR}/test/$ENV{CONTAINER_FLAVOR}/integration-tests.bats")

CMakePresets.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"version": 8,
3+
"configurePresets": [
4+
{
5+
"name": "default",
6+
"binaryDir": "${sourceDir}/build/${presetName}",
7+
"generator": "Ninja"
8+
}
9+
],
10+
"buildPresets": [
11+
{
12+
"name": "default",
13+
"configurePreset": "default"
14+
}
15+
],
16+
"testPresets": [
17+
{
18+
"output": {
19+
"quiet": true
20+
},
21+
"name": "default",
22+
"configurePreset": "default"
23+
}
24+
]
25+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ The resulting containers can be used in a `.devcontainer.json` file or in a `.de
120120
## Community
121121

122122
This project uses a [code of conduct](.github/CODE_OF_CONDUCT.md) to define expected conduct in our community. Instances of
123-
abusive, harassing, or otherwise unacceptable behavior may be reported to the repository administrators by using the [Report content](https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam) functionality of GitHub.
123+
abusive, harassing, or otherwise unacceptable behavior may be reported to the repository administrators by using the [report content](https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam) functionality of GitHub.
124124

125125
## Changelog
126126

@@ -132,11 +132,11 @@ This project uses [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.htm
132132

133133
### Build & Test
134134

135-
The containers can be built and tested locally by importing this repository in VS Code with the [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) plug-in installed. As a prerequisite Docker needs to be installed on the host system. Alternatively a GitHub Codespace can be started.
135+
The containers can be built and tested locally by importing this repository in VS Code with the [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) plug-in installed. As a prerequisite an OCI compatible container engine needs to be installed on the host system. Alternatively a GitHub Codespace can be started.
136136

137137
#### Running the Integration Tests
138138

139-
A test task is available to run the included `bats` tests. Choose `Tasks: Run Test Task` from the command pallette (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>).
139+
Run the included `bats` integration tests from the test explorer. Alternatively run all tests with <kbd>Ctrl</kbd> + <kbd>;</kbd> <kbd>A</kbd>.
140140

141141
#### Running the Acceptance Tests
142142

test/cpp/integration-tests.bats

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ setup_file() {
66
# Installing the Windows SDK/CRT takes a long time.
77
# When still valid, use the installation from cache.
88

9-
xwin --accept-license --cache-dir .xwin-hash list
10-
HASH_LIST_MANIFEST=$(sha256sum .xwin-hash/dl/manifest*.json | awk '{ print $1 }')
9+
xwin --accept-license --cache-dir ${BATS_TEST_DIRNAME}/.xwin-hash list
10+
HASH_LIST_MANIFEST=$(sha256sum ${BATS_TEST_DIRNAME}/.xwin-hash/dl/manifest*.json | awk '{ print $1 }')
1111
HASH_CACHED_MANIFEST=
1212

13-
if [[ -d .xwin-cache/dl ]]; then
14-
HASH_CACHED_MANIFEST=$(sha256sum .xwin-cache/dl/manifest*.json | awk '{ print $1 }')
13+
if [[ -d ${BATS_TEST_DIRNAME}/.xwin-cache/dl ]]; then
14+
HASH_CACHED_MANIFEST=$(sha256sum ${BATS_TEST_DIRNAME}/.xwin-cache/dl/manifest*.json | awk '{ print $1 }')
1515
fi
1616

1717
if [[ $HASH_LIST_MANIFEST != $HASH_CACHED_MANIFEST ]]; then
18-
xwin --accept-license splat --preserve-ms-arch-notation
18+
xwin --accept-license --cache-dir ${BATS_TEST_DIRNAME}/.xwin-cache splat --preserve-ms-arch-notation
1919
fi
2020

21-
cp -r .xwin-cache/splat/ /winsdk
21+
ln -sf ${BATS_TEST_DIRNAME}/.xwin-cache/splat/ /winsdk
2222
}
2323

2424
teardown_file() {
25-
rm -rf .xwin-hash/ /winsdk
25+
rm -rf ${BATS_TEST_DIRNAME}/.xwin-hash/ /winsdk
2626
}
2727

2828
setup() {
2929
load '/usr/local/bats-support/load'
3030
load '/usr/local/bats-assert/load'
3131

32-
pushd workspace
32+
pushd ${BATS_TEST_DIRNAME}/workspace
3333
}
3434

3535
teardown() {

test/cpp/workspace/test/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ if (ENABLE_COVERAGE_TEST)
1313

1414
add_executable(test-coverage EXCLUDE_FROM_ALL test.cpp)
1515
target_compile_options(test-coverage PRIVATE
16-
-g -O0 --coverage -fprofile-arcs -ftest-coverage -fno-inline
16+
-g -O0 --coverage -fcondition-coverage -fno-inline
1717
)
18-
target_link_libraries(test-coverage PRIVATE gmock_main gcov)
18+
target_link_options(test-coverage PRIVATE --coverage)
19+
target_link_libraries(test-coverage PRIVATE gmock_main)
20+
1921
add_test(NAME test-coverage COMMAND test-coverage)
2022
endif()
2123

0 commit comments

Comments
 (0)