From 927df0c00a0cfac16720431cbc74702dbbbdcf9f Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:43:27 +0200 Subject: [PATCH] chore: add requirements and tests --- .github/workflows/ci.yml | 2 +- .github/workflows/verify-specification.yml | 2 +- .vscode/tasks.json | 2 +- specification/requirements/HEAD-1.0.md | 21 ++++++++++ specification/requirements/HEAD-2.0.md | 21 ++++++++++ specification/requirements/HEAD-2.1.md | 13 +++++++ specification/requirements/REQ-0001.md | 11 +++--- specification/tests/HEAD-1.0.md | 38 +++++++++++++++++++ specification/tests/HEAD-2.0.md | 13 +++++++ specification/tests/TEST-0001.md | 15 ++++++-- specification/tests/TEST-0002.md | 9 +++++ specification/tests/assets/TESTSUITE.md | 24 ------------ .../tests/assets => tests}/CMakeLists.txt | 0 .../tests/assets => tests}/CMakePresets.json | 0 .../assets => tests}/clang-cl/CMakeLists.txt | 0 .../tests/assets => tests}/clang-cl/main.cpp | 0 .../assets => tests}/clang-cl/toolchain.cmake | 0 .../clang-tools/CMakeLists.txt | 0 .../assets => tests}/clang-tools/main.cpp | 0 .../clang-tools/unformatted.cpp | 0 .../assets => tests}/coverage/CMakeLists.txt | 0 .../tests/assets => tests}/coverage/test.cpp | 0 .../assets => tests}/fuzzing/CMakeLists.txt | 0 .../tests/assets => tests}/fuzzing/main.cpp | 0 .../gcc-arm-none-eabi/CMakeLists.txt | 0 .../gcc-arm-none-eabi/main.cpp | 0 .../gcc-arm-none-eabi/toolchain.cmake | 0 .../tests/assets => tests}/gcc/CMakeLists.txt | 0 .../tests/assets => tests}/gcc/main-fail.cpp | 0 .../tests/assets => tests}/gcc/main.cpp | 0 .../assets => tests}/mutation/CMakeLists.txt | 0 .../tests/assets => tests}/mutation/test.cpp | 0 tests/testsuite.bats | 35 +++++++++++++++++ 33 files changed, 170 insertions(+), 36 deletions(-) create mode 100644 specification/requirements/HEAD-1.0.md create mode 100644 specification/requirements/HEAD-2.0.md create mode 100644 specification/requirements/HEAD-2.1.md create mode 100644 specification/tests/HEAD-1.0.md create mode 100644 specification/tests/HEAD-2.0.md create mode 100644 specification/tests/TEST-0002.md delete mode 100644 specification/tests/assets/TESTSUITE.md rename {specification/tests/assets => tests}/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/CMakePresets.json (100%) rename {specification/tests/assets => tests}/clang-cl/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/clang-cl/main.cpp (100%) rename {specification/tests/assets => tests}/clang-cl/toolchain.cmake (100%) rename {specification/tests/assets => tests}/clang-tools/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/clang-tools/main.cpp (100%) rename {specification/tests/assets => tests}/clang-tools/unformatted.cpp (100%) rename {specification/tests/assets => tests}/coverage/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/coverage/test.cpp (100%) rename {specification/tests/assets => tests}/fuzzing/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/fuzzing/main.cpp (100%) rename {specification/tests/assets => tests}/gcc-arm-none-eabi/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/gcc-arm-none-eabi/main.cpp (100%) rename {specification/tests/assets => tests}/gcc-arm-none-eabi/toolchain.cmake (100%) rename {specification/tests/assets => tests}/gcc/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/gcc/main-fail.cpp (100%) rename {specification/tests/assets => tests}/gcc/main.cpp (100%) rename {specification/tests/assets => tests}/mutation/CMakeLists.txt (100%) rename {specification/tests/assets => tests}/mutation/test.cpp (100%) create mode 100644 tests/testsuite.bats diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49591f9c..6fc8cac8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: - name: Run Tests run: | set -Eeuo pipefail - docker run --rm --mount type=bind,src="$(pwd)/specification/requirements/tests/assets",dst=/ws -w /ws ${{ github.repository }}:test bats --formatter junit testsuite.bats | tee test-report.xml + docker run --rm --mount type=bind,src="$(pwd)/tests",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: diff --git a/.github/workflows/verify-specification.yml b/.github/workflows/verify-specification.yml index ed27063c..c3925286 100644 --- a/.github/workflows/verify-specification.yml +++ b/.github/workflows/verify-specification.yml @@ -14,4 +14,4 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: | pip install doorstop==3.0b4 - doorstop >> "$GITHUB_STEP_SUMMARY" + doorstop -e 2>> "$GITHUB_STEP_SUMMARY" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 16d6146f..79ff5c3d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -10,7 +10,7 @@ "command": "bats", "args": ["testsuite.bats"], "options": { - "cwd": "${workspaceFolder}/test" + "cwd": "${workspaceFolder}/tests" }, "problemMatcher": { "owner": "bats", diff --git a/specification/requirements/HEAD-1.0.md b/specification/requirements/HEAD-1.0.md new file mode 100644 index 00000000..a2328272 --- /dev/null +++ b/specification/requirements/HEAD-1.0.md @@ -0,0 +1,21 @@ +--- +active: true +derived: false +level: 1.0 +links: [] +normative: false +ref: '' +reviewed: XYLWU-Hs44a06GH7ROEbzshG7qwQoerFvs4kHZ5ZXxw= +--- + +# Introduction + +This document describes the requirements for amp-devcontainer. + +## Abstract + +amp-devcontainer is a [devcontainer](https://containers.dev/) tailored towards modern C++ development. + +## Definitions of key words + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119). \ No newline at end of file diff --git a/specification/requirements/HEAD-2.0.md b/specification/requirements/HEAD-2.0.md new file mode 100644 index 00000000..8df78dc3 --- /dev/null +++ b/specification/requirements/HEAD-2.0.md @@ -0,0 +1,21 @@ +--- +active: true +derived: false +level: 2.0 +links: [] +normative: false +ref: '' +reviewed: NGwtZc9fjLTn_jPUJIaBlnRaPoeXCrhpDtoTutuvI_o= +--- + +# Requirements + +This document describes the requirements for amp-devcontainer. + +## Abstract + +amp-devcontainer is a [devcontainer](https://containers.dev/) tailored towards modern C++ development. + +## Definitions of key words + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119). \ No newline at end of file diff --git a/specification/requirements/HEAD-2.1.md b/specification/requirements/HEAD-2.1.md new file mode 100644 index 00000000..5e5ac26c --- /dev/null +++ b/specification/requirements/HEAD-2.1.md @@ -0,0 +1,13 @@ +--- +active: true +derived: false +level: 2.1.0 +links: [] +normative: false +ref: '' +reviewed: 6nNXJvAjfy6ZFiOHZUk6pAYIH6s354g9yKW7Nlg4sBQ= +--- + +# Compilation + +This chapter list the requirements that pertain to compilation. \ No newline at end of file diff --git a/specification/requirements/REQ-0001.md b/specification/requirements/REQ-0001.md index 74c27cad..31126542 100644 --- a/specification/requirements/REQ-0001.md +++ b/specification/requirements/REQ-0001.md @@ -1,16 +1,17 @@ --- active: true derived: false -level: 1.0 +level: 2.1.1 links: [] normative: true ref: '' -reviewed: YlXqzBrdPVyJ1kOTSXb5BVd0U3qRt39jT_lcpotaxh8= +reviewed: BahQmI-3t190oidQmtYsgRnqsF5ZInkZITtpW1PvQgY= --- -**amp-devcontainer __shall__ be able to compile source-code into a working executable** +# Host compilation + +**amp-devcontainer *SHALL* be able to compile source-code into a working executable** Compiling source-code into working executables, able to run inside the container, can be necessary in several scenarios e.g. -- When targeting the container host system and architecture - When running tests inside the container -- When building plug-ins, extensions, code generators, or other additional tools \ No newline at end of file +- When building plug-ins, extensions, code generators, or other additional tools that need to run inside the container \ No newline at end of file diff --git a/specification/tests/HEAD-1.0.md b/specification/tests/HEAD-1.0.md new file mode 100644 index 00000000..d5c0f004 --- /dev/null +++ b/specification/tests/HEAD-1.0.md @@ -0,0 +1,38 @@ +--- +active: true +derived: false +level: 1.0 +links: [] +normative: false +ref: '' +reviewed: BQb72tLqNOlSKhoixy2-c7fRw2CcinT4qeWWv7gOSms= +--- + +# Purpose + +This document describes the test cases to be executed as part of the verification of amp-devcontainer. + +``` {.sh file=tests/testsuite.bats} +#!/usr/bin/env bats + +setup() { + #!/usr/bin/env bats + <> +} + +teardown() { + #!/usr/bin/env bats + <> +} + +<> +``` + +``` {.sh #setup} +load '/usr/local/bats-support/load' +load '/usr/local/bats-assert/load' +``` + +``` {.sh #teardown} +rm -rf build +``` diff --git a/specification/tests/HEAD-2.0.md b/specification/tests/HEAD-2.0.md new file mode 100644 index 00000000..594436bc --- /dev/null +++ b/specification/tests/HEAD-2.0.md @@ -0,0 +1,13 @@ +--- +active: true +derived: false +level: 2.0 +links: [] +normative: false +ref: '' +reviewed: rLndHKdsx6QMzsyN_INI_Sil5SClUFemu3pBDzOri48= +--- + +# Test cases + +This chapter contains a description and implementation of automated test cases used to verify the requirements of amp-devcontainer. \ No newline at end of file diff --git a/specification/tests/TEST-0001.md b/specification/tests/TEST-0001.md index 54b16b3a..90c0c702 100644 --- a/specification/tests/TEST-0001.md +++ b/specification/tests/TEST-0001.md @@ -1,16 +1,23 @@ --- active: true derived: false -level: 1.0 +level: 2.1 links: -- REQ-0001: YlXqzBrdPVyJ1kOTSXb5BVd0U3qRt39jT_lcpotaxh8= +- REQ-0001: BahQmI-3t190oidQmtYsgRnqsF5ZInkZITtpW1PvQgY= normative: true ref: '' -reviewed: 7TzxCCfQzn1Pc7-N6_G-zn3G43Iw6fccUg8flhUq42o= +references: +- keyword: TEST-0001 + path: tests/testsuite.bats + type: file +reviewed: -ARwwSIY4W0KIWljxJ_o4qFstQkH79Jo_B_X0Ov_rTM= --- +# Test host compilation + ``` {.sh #testcase} -"valid code input should result in working executable using host compiler" { +# bats test_tags=TC:TEST-0001 +@test "valid code input should result in working executable using host compiler" { run cmake --preset gcc assert_success diff --git a/specification/tests/TEST-0002.md b/specification/tests/TEST-0002.md new file mode 100644 index 00000000..e6dc5764 --- /dev/null +++ b/specification/tests/TEST-0002.md @@ -0,0 +1,9 @@ +--- +active: true +derived: false +level: 2.2 +links: [] +normative: true +ref: '' +reviewed: null +--- \ No newline at end of file diff --git a/specification/tests/assets/TESTSUITE.md b/specification/tests/assets/TESTSUITE.md deleted file mode 100644 index 2a22dc1f..00000000 --- a/specification/tests/assets/TESTSUITE.md +++ /dev/null @@ -1,24 +0,0 @@ -``` {.sh file=specification/tests/assets/testsuite.bats} -setup() { - <> -} - -teardown() { - <> -} - -<> -``` - -``` {.sh #setup} -load '/usr/local/bats-support/load' -load '/usr/local/bats-assert/load' -``` - -``` {.sh #teardown} -rm -rf build -``` - -``` {.sh #testbody} -@test <> -``` diff --git a/specification/tests/assets/CMakeLists.txt b/tests/CMakeLists.txt similarity index 100% rename from specification/tests/assets/CMakeLists.txt rename to tests/CMakeLists.txt diff --git a/specification/tests/assets/CMakePresets.json b/tests/CMakePresets.json similarity index 100% rename from specification/tests/assets/CMakePresets.json rename to tests/CMakePresets.json diff --git a/specification/tests/assets/clang-cl/CMakeLists.txt b/tests/clang-cl/CMakeLists.txt similarity index 100% rename from specification/tests/assets/clang-cl/CMakeLists.txt rename to tests/clang-cl/CMakeLists.txt diff --git a/specification/tests/assets/clang-cl/main.cpp b/tests/clang-cl/main.cpp similarity index 100% rename from specification/tests/assets/clang-cl/main.cpp rename to tests/clang-cl/main.cpp diff --git a/specification/tests/assets/clang-cl/toolchain.cmake b/tests/clang-cl/toolchain.cmake similarity index 100% rename from specification/tests/assets/clang-cl/toolchain.cmake rename to tests/clang-cl/toolchain.cmake diff --git a/specification/tests/assets/clang-tools/CMakeLists.txt b/tests/clang-tools/CMakeLists.txt similarity index 100% rename from specification/tests/assets/clang-tools/CMakeLists.txt rename to tests/clang-tools/CMakeLists.txt diff --git a/specification/tests/assets/clang-tools/main.cpp b/tests/clang-tools/main.cpp similarity index 100% rename from specification/tests/assets/clang-tools/main.cpp rename to tests/clang-tools/main.cpp diff --git a/specification/tests/assets/clang-tools/unformatted.cpp b/tests/clang-tools/unformatted.cpp similarity index 100% rename from specification/tests/assets/clang-tools/unformatted.cpp rename to tests/clang-tools/unformatted.cpp diff --git a/specification/tests/assets/coverage/CMakeLists.txt b/tests/coverage/CMakeLists.txt similarity index 100% rename from specification/tests/assets/coverage/CMakeLists.txt rename to tests/coverage/CMakeLists.txt diff --git a/specification/tests/assets/coverage/test.cpp b/tests/coverage/test.cpp similarity index 100% rename from specification/tests/assets/coverage/test.cpp rename to tests/coverage/test.cpp diff --git a/specification/tests/assets/fuzzing/CMakeLists.txt b/tests/fuzzing/CMakeLists.txt similarity index 100% rename from specification/tests/assets/fuzzing/CMakeLists.txt rename to tests/fuzzing/CMakeLists.txt diff --git a/specification/tests/assets/fuzzing/main.cpp b/tests/fuzzing/main.cpp similarity index 100% rename from specification/tests/assets/fuzzing/main.cpp rename to tests/fuzzing/main.cpp diff --git a/specification/tests/assets/gcc-arm-none-eabi/CMakeLists.txt b/tests/gcc-arm-none-eabi/CMakeLists.txt similarity index 100% rename from specification/tests/assets/gcc-arm-none-eabi/CMakeLists.txt rename to tests/gcc-arm-none-eabi/CMakeLists.txt diff --git a/specification/tests/assets/gcc-arm-none-eabi/main.cpp b/tests/gcc-arm-none-eabi/main.cpp similarity index 100% rename from specification/tests/assets/gcc-arm-none-eabi/main.cpp rename to tests/gcc-arm-none-eabi/main.cpp diff --git a/specification/tests/assets/gcc-arm-none-eabi/toolchain.cmake b/tests/gcc-arm-none-eabi/toolchain.cmake similarity index 100% rename from specification/tests/assets/gcc-arm-none-eabi/toolchain.cmake rename to tests/gcc-arm-none-eabi/toolchain.cmake diff --git a/specification/tests/assets/gcc/CMakeLists.txt b/tests/gcc/CMakeLists.txt similarity index 100% rename from specification/tests/assets/gcc/CMakeLists.txt rename to tests/gcc/CMakeLists.txt diff --git a/specification/tests/assets/gcc/main-fail.cpp b/tests/gcc/main-fail.cpp similarity index 100% rename from specification/tests/assets/gcc/main-fail.cpp rename to tests/gcc/main-fail.cpp diff --git a/specification/tests/assets/gcc/main.cpp b/tests/gcc/main.cpp similarity index 100% rename from specification/tests/assets/gcc/main.cpp rename to tests/gcc/main.cpp diff --git a/specification/tests/assets/mutation/CMakeLists.txt b/tests/mutation/CMakeLists.txt similarity index 100% rename from specification/tests/assets/mutation/CMakeLists.txt rename to tests/mutation/CMakeLists.txt diff --git a/specification/tests/assets/mutation/test.cpp b/tests/mutation/test.cpp similarity index 100% rename from specification/tests/assets/mutation/test.cpp rename to tests/mutation/test.cpp diff --git a/tests/testsuite.bats b/tests/testsuite.bats new file mode 100644 index 00000000..db21a177 --- /dev/null +++ b/tests/testsuite.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# ~/~ begin <>[init] + +setup() { + #!/usr/bin/env bats + #!/usr/bin/env bats + # ~/~ begin <>[init] + load '/usr/local/bats-support/load' + load '/usr/local/bats-assert/load' + # ~/~ end +} + +teardown() { + #!/usr/bin/env bats + #!/usr/bin/env bats + # ~/~ begin <>[init] + rm -rf build + # ~/~ end +} + +# ~/~ begin <>[init] +# bats test_tags=TC:TEST-0001 +@test "valid code input should result in working executable using host compiler" { + run cmake --preset gcc + assert_success + + run cmake --build --preset gcc + assert_success + + run build/gcc/gcc/test-gcc + assert_success + assert_output "Hello World!" +} +# ~/~ end +# ~/~ end \ No newline at end of file