Skip to content

Commit

Permalink
test: add test for docker cli
Browse files Browse the repository at this point in the history
  • Loading branch information
rjaegers committed Feb 16, 2024
1 parent 8a3c619 commit 96ab54c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Run Tests
run: |
set -Eeuo pipefail
docker run --rm --mount type=bind,src="$(pwd)/test",dst=/ws -w /ws ${{ github.repository }}:test bats --formatter junit testsuite.bats | tee test-report.xml
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src="$(pwd)/test",dst=/ws -w /ws ${{ github.repository }}:test bats --formatter junit testsuite.bats | tee test-report.xml
- uses: EnricoMi/publish-unit-test-result-action@ca89ad036b5fcd524c1017287fb01b5139908408 # v2.11.0
if: always()
with:
Expand Down
22 changes: 16 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run Tests",
"type": "shell",
"group": "test",
"group": {
"kind": "test",
"isDefault": true
},
"command": "bats",
"args": ["testsuite.bats"],
"args": [
"testsuite.bats"
],
"options": {
"cwd": "${workspaceFolder}/test"
},
"presentation": {
"reveal": "always",
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
},
"problemMatcher": {
"owner": "bats",
"source": "bats",
"owner": "bats",
"fileLocation": ["relative", "${workspaceFolder}/test"],
"pattern": [
{
"regexp": "^.*test file(.*), line (\\d+)",
"file": 1,
"location": 2
"line": 2
},
{
"regexp": "^(.*failed)",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For the full list of all included tools and tool versions see the [Dependency Gr

The container can be built and tested locally by importing this repository in VS Code with the `Dev Containers` (ms-vscode-remote.remote-containers) plug-in installed. As a prerequisite Docker needs to be installed on the host system. As an alternative a GitHub Codespace can be started.

A test task is available to run the included `bats` tests. Choose `Tasks: Run Task` from the command pallette and choose `Run Tests`.
A test task is available to run the included `bats` tests. Choose `Tasks: Run Test Task` from the command pallette.

## Verify image signature

Expand Down
19 changes: 13 additions & 6 deletions test/testsuite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ setup_file() {
xwin --accept-license splat --preserve-ms-arch-notation
fi

cp -r .xwin-cache/splat/ /winsdk
cp -r .xwin-cache/splat/* /winsdk/
}

teardown_file() {
rm -rf .xwin-hash/ /winsdk
rm -rf .xwin-hash/ /winsdk/*
}

setup() {
Expand Down Expand Up @@ -160,7 +160,7 @@ teardown() {
}

# bats test_tags=tc:9
@test "coverage information should be generated when running tests" {
@test "coverage information should be generated when running a testsuite" {
run cmake --preset coverage
assert_success

Expand All @@ -177,7 +177,7 @@ teardown() {
}

# bats test_tags=tc:10
@test "fuzzing an executable should be supported" {
@test "crashes should be detected when fuzzing an executable" {
run cmake --preset clang
assert_success

Expand All @@ -190,7 +190,7 @@ teardown() {
}

# bats test_tags=tc:11
@test "mutation testing an executable should be supported" {
@test "a mutation score should be calculated when mutation testing a testsuite" {
run cmake --preset mutation
assert_success

Expand All @@ -213,7 +213,7 @@ teardown() {
assert_success
}

# bats test_tags=tc14
# bats test_tags=tc:14
@test "clangd should be able to analyze source files" {
run clangd --check=gcc/main.cpp
assert_success
Expand All @@ -235,3 +235,10 @@ teardown() {
assert_success
assert_output "Hello World!"
}

# bats test_tags=tc:18
@test "when the docker socket is mounted, using the docker cli should give access to the host docker daemon" {
run docker info
assert_success
assert_output --partial "Server Version:"
}

0 comments on commit 96ab54c

Please sign in to comment.