From cb5873b732325c71e62a48ba4a192770ed34980f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 10 Jul 2025 01:50:46 +0000 Subject: [PATCH] [wip] unit testing - tooling for code coverage measurement --- .devcontainer/devcontainer.json | 1 - .gitignore | 4 +++ .vscode/settings.json | 1 - .vscode/tasks.json | 63 +++++++++++++++++++++++++-------- 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f409fe3..3cd3f2f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -47,7 +47,6 @@ "extensions": [ "mhutchie.git-graph", "Gruntfuggly.todo-tree", - "ms-vscode.live-server", "ryanluker.vscode-coverage-gutters" ] } diff --git a/.gitignore b/.gitignore index 39f9b12..ae367dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# code coverage reports +coverage/ + + # https://github.com/github/gitignore/raw/refs/heads/main/Rust.gitignore # Generated by Cargo diff --git a/.vscode/settings.json b/.vscode/settings.json index faa63ed..4eb6d7e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -43,7 +43,6 @@ "black" ], "todo-tree.highlights.useColourScheme": true, - "coverage-gutters.coverageReportFileName": "target/llvm-cov/**/index.html", // // override the default setting (`cargo check --all-targets`) which produces the following error // // "can't find crate for `test`" when the default compilation target is a no_std target // "rust-analyzer.checkOnSave.allTargets": false, diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 888be50..a80e09b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,9 +5,6 @@ "label": "Build Project", "type": "cargo", "command": "build", - // "presentation": { - // "reveal": "silent" - // }, "problemMatcher": "$rustc", "group": "build" }, @@ -62,18 +59,6 @@ "problemMatcher": "$rustc", "group": "test" }, - { - "label": "Run Coverage", - "type": "cargo", - "command": "llvm-cov", - "args": [ - "--lcov", - "--output-path" , - "target/lcov.info" - ], - "problemMatcher": "$rustc", - "group": "test" - }, // { // "label": "Run Integration Tests", // "type": "cargo", @@ -85,6 +70,54 @@ // "problemMatcher": "$rustc", // "group": "test" // }, + { + "label": "Test Coverage", + "hide": true, + "type": "cargo", + "command": "llvm-cov", + "args": [], + "problemMatcher": "$rustc", + "group": "test", + }, + { + "label": "Report Coverage (html)", + "hide": true, + "type": "cargo", + "command": "llvm-cov", + "args": [ + "report", + "--html", + "--output-dir" , + "coverage", + ], + "problemMatcher": "$rustc", + "group": "test" + }, + { + "label": "Report Coverage (lcov)", + "hide": true, + "type": "cargo", + "command": "llvm-cov", + "args": [ + "report", + "--lcov", + "--output-path" , + "coverage/lcov.info", + ], + "problemMatcher": "$rustc", + "group": "test" + }, + { + "label": "Run Coverage", + "type": "shell", + "dependsOn": [ + "Test Coverage", + "Report Coverage (html)", + "Report Coverage (lcov)", + ], + "dependsOrder": "sequence", + "group": "test" + }, { "label": "Run All Tests", "type": "shell",