{"id":21363625,"url":"https://github.com/fredericbonnet/cmake-test-explorer","last_synced_at":"2025-07-13T03:31:53.265Z","repository":{"id":41512189,"uuid":"202696364","full_name":"fredericbonnet/cmake-test-explorer","owner":"fredericbonnet","description":"CMake Test Explorer for Visual Studio Code","archived":false,"fork":false,"pushed_at":"2024-05-04T20:06:48.000Z","size":337,"stargazers_count":7,"open_issues_count":13,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-04T21:21:14.592Z","etag":null,"topics":["c","cmake","cpp","ctest","test-automation","test-explorer","testing","vscode","vscode-extension"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fredericbonnet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-16T09:09:31.000Z","updated_at":"2024-05-04T20:06:51.000Z","dependencies_parsed_at":"2024-04-08T20:49:27.927Z","dependency_job_id":null,"html_url":"https://github.com/fredericbonnet/cmake-test-explorer","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":"hbenl/vscode-example-test-adapter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fcmake-test-explorer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fcmake-test-explorer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fcmake-test-explorer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fcmake-test-explorer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredericbonnet","download_url":"https://codeload.github.com/fredericbonnet/cmake-test-explorer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225851315,"owners_count":17534286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cmake","cpp","ctest","test-automation","test-explorer","testing","vscode","vscode-extension"],"created_at":"2024-11-22T06:20:19.678Z","updated_at":"2025-07-13T03:31:53.259Z","avatar_url":"https://github.com/fredericbonnet.png","language":"TypeScript","readme":"# CMake Test Explorer for Visual Studio Code\n\nRun your [CMake] tests using Visual Studio Code's [native Testing UI][vscode-testing].\n\n## Features\n\n- Autodects CMake build directories in workspace\n- Reasonable defaults for zero-config\n- Integrates with CMake Tools\n- Runs tests in parallel\n- Supports custom test properties for advanced features like hierarchical suites\n  and test locations\n\n## Configuration\n\n| Property                           | Description                                                                                                                                                                                                                                                                                        | Default value                                                        |\n| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |\n| `cmakeExplorer.buildConfig`        | Name of the CMake build configuration. Can be set to any standard or custom configuration name (e.g. `Debug`, `Release`, `RelWithDebInfo`, `MinSizeRel` ). Case-insensitive.                                                                                                                       | `${buildType}` (see [Variable substitution](#variable-substitution)) |\n| `cmakeExplorer.cmakeIntegration`   | Integrate with the [CMake Tools][cmake-tools] extension for additional variables. See [Variable substitution](#variable-substitution) for more info.                                                                                                                                               | `true`                                                               |\n| `cmakeExplorer.debugConfig`        | Custom debug configuration to use. See [Debugging](#debugging) for more info.                                                                                                                                                                                                                      | Empty                                                                |\n| `cmakeExplorer.parallelJobs`       | Maximum number of parallel test jobs to run (zero=autodetect, 1 or negative=disable). See [Parallel test jobs](#parallel-test-jobs) for more info.                                                                                                                                                 | 0                                                                    |\n| `cmakeExplorer.extraCtestLoadArgs` | Extra command-line arguments passed to CTest at load time. For example, `-R foo` will only load the tests containing the string `foo`.                                                                                                                                                             | Empty                                                                |\n| `cmakeExplorer.extraCtestRunArgs`  | Extra command-line arguments passed to CTest at run time. For example, `-V` will enable verbose output from tests.                                                                                                                                                                                 | Empty                                                                |\n| `cmakeExplorer.extraCtestEnvVars`  | Extra environment variables passed to CTest at run time.                                                                                                                                                                                                                                           | Empty                                                                |\n| `cmakeExplorer.suiteDelimiter`     | Delimiter used to split CMake test names into suite/test hierarchy. For example, if you name your tests `suite1/subsuite1/test1`, `suite1/subsuite1/test2`, `suite2/subsuite3/test4`, etc. you may set this to `/` in order to group your suites into a tree. If empty, the tests are not grouped. | Empty                                                                |\n| `cmakeExplorer.testFileVar`        | CTest environment variable defined for a test, giving the path of the source file containing the test. See [Source files](#source-files) for more info.                                                                                                                                            | Empty                                                                |\n| `cmakeExplorer.testLineVar`        | CTest environment variable defined for a test, giving the line number within the file where the test definition starts (if known). See [Source files](#source-files) for more info.                                                                                                                | Empty                                                                |\n| `cmakeExplorer.errorPattern`       | Regular expression used to match error lines in test outputs. See [Error pattern](#error-pattern) for more info.                                                                                                                                                                                   | GCC-style pattern                                                    |\n\n## Variable substitution\n\nSome options support the replacement of special values in their string value by\nusing a `${variable}` syntax.\n\nThe following built-in variables are expanded:\n\n| Variable             | Expansion                                      |\n| -------------------- | ---------------------------------------------- |\n| `${workspaceFolder}` | The full path to the workspace root directory. |\n\nEnvironments variables are prefixed with `env:`. For example `${env:HOME}` will\nbe substituted with the home path on Unix systems.\n\n| Variable           | Expansion                                                         |\n| ------------------ | ----------------------------------------------------------------- |\n| `${env:\u003cVARNAME\u003e}` | The value of the environment variable `VARNAME` at session start. |\n\n_(Note: On Windows, variable names are case insensitive but must be uppercase\nfor `env:` substitition to work properly)_\n\nAdditionally, if the [CMake Tools][cmake-tools] extension is active in the\ncurrent workspace and `cmakeExplorer.cmakeIntegration` is enabled, then the\nfollowing variables can be used:\n\n| Variable            | Expansion                                                                   | Default value |\n| ------------------- | --------------------------------------------------------------------------- | ------------- |\n| `${buildType}`      | The current CMake build type. For example: `Debug`, `Release`, `MinSizeRel` | `Debug`       |\n| `${buildDirectory}` | The full path to the current CMake build directory.                         | Empty         |\n\nIf you want the extension to infer the right configuration automatically from\nCMake Tools, simply keep these default settings:\n\n| Property                    | Value          |\n| --------------------------- | -------------- |\n| `cmakeExplorer.buildConfig` | `${buildType}` |\n\nIf these variables are missing from the current settings (for example, if the\nCMake Tools extension is missing or disabled) then they are substituted with an\nempty string, falling back to default behavior.\n\nNote that any change to the CMake Tools configuration, either from the settings\nor the status bar, requires a manual test reload from the Testing UI.\n\n## Source files\n\nThe Testing UI has a feature to link tests with their source files. CMake\nprovides the [`set_tests_properties()`][cmake-set_tests_properties] command to\nassociate tests with various metadata, however it only support a predefined\n[list of properties][cmake-test-properties], and none of them seems suitable for\nthis purpose. To support this feature anyway, the extension expects that the\nfile path and line number be passed as test environment variables using the\n[`ENVIRONMENT`][cmake-environment] property, like so:\n\n```\nadd_test(\n    NAME \u003cname\u003e\n    COMMAND \u003ccommand\u003e [\u003cargs\u003e ...]\n)\nset_tests_properties(\u003cname\u003e PROPERTIES\n    ENVIRONMENT \"TEST_FILE=\u003cfilename\u003e;TEST_LINE=\u003cline\u003e\"\n)\n```\n\nHere we are using `TEST_FILE` and `TEST_LINE` environment variables but you are\nfree to choose other variable names. You can then edit the\n`cmakeExplorer.testFileVar` and `cmakeExplorer.testLineVar` settings\naccordingly, and you should see an extra '**Go to Test**' entry in the\ncontextual menu.\n\nNote that the `cmakeExplorer.testFileVar` setting must be set for these features\nto work, however if the `cmakeExplorer.testLineVar` setting is missing or the\nvariable is not set for a given test then the '**Go to Test**' will simply open\nthe file.\n\n## Error pattern\n\nThe `cmakeExplorer.errorPattern` setting can be used to capture error messages\non the test output. If the `testExplorer.useNativeTesting` setting is enabled,\nthe captured messages will be displayed in the file editor next to the line\nwhere the error occurred.\n\nThis setting expects a regular expression string with the following named\ncapturing groups:\n\n- `file`\n- `line`\n- `severity` (optional)\n- `message`\n\nSee the [MDN documentation on regular expression groups][re-groups] for more\ninformation on the syntax. For example, here is the default value that captures\nGCC-style error messages:\n\n```\n^(?\u003cfile\u003e[^\u003c].*?):(?\u003cline\u003e\\\\d+):\\\\d*:?\\\\s+(?\u003cseverity\u003e(?:fatal\\\\s+)?(?:warning|error)):\\\\s+(?\u003cmessage\u003e.*)$\n```\n\nThis pattern will match the following error message:\n\n```\n/path/to/my/file.c:123: error: unexpected value\n```\n\nThe captured groups will be:\n\n| Name       | Value                |\n| ---------- | -------------------- |\n| `file`     | `/path/to/my/file.c` |\n| `line`     | 123                  |\n| `severity` | `error`              |\n| `message`  | `unexpected value`   |\n\nThe advantage of using named groups is that their order does not matter. Let's\nconsider the following error message:\n\n```\nERROR: assertion failed on line 123 (file=/path/to/my/file.c)\n```\n\nTo capture this message you could use the following syntax:\n\n```\n^(?\u003cseverity\u003eERROR):\\s+(?\u003cmessage\u003e.*)\\s+on line (?\u003cline\u003e\\d+) \\(file=(?\u003cfile\u003e.+)\\)$\n```\n\n## Debugging\n\nThe extension comes pre-configured with sensible defaults for debugging tests:\n\n```json\n{\n\t\"name\": \"CTest\",\n\t\"type\": \"cppdbg\",\n\t\"request\": \"launch\",\n\t\"windows\": {\n\t\t\"type\": \"cppvsdbg\"\n\t},\n\t\"linux\": {\n\t\t\"type\": \"cppdbg\",\n\t\t\"MIMode\": \"gdb\"\n\t},\n\t\"osx\": {\n\t\t\"type\": \"cppdbg\",\n\t\t\"MIMode\": \"lldb\"\n\t}\n}\n```\n\nYou can also use a custom configuration defined in the standard `launch.json`.\nTo do so, edit the `cmakeExplorer.debugConfig` setting with the name of the\ndebug configuration to use.\n\nDebugging a test will overwrite the following debug configuration fields with\nvalues from the CTest metadata:\n\n| Field     | Value                            |\n| --------- | -------------------------------- |\n| `name`    | `CTest ${test name}`             |\n| `program` | CTest `COMMAND` option           |\n| `args`    | CTest arguments                  |\n| `cwd`     | CTest `WORKING_DIRECTORY` option |\n\nFor example, if you want the debugger to stop at the entry point of your tests,\nadd the following config in your `launch.json` then set\n`cmakeExplorer.debugConfig` to \"`myCustomDebugConfig`\" :\n\n```json\n{\n\t\"name\": \"myCustomDebugConfig\",\n\t\"type\": \"cppdbg\",\n\t\"request\": \"launch\",\n\t\"stopAtEntry\": true,\n\t\"windows\": {\n\t\t\"type\": \"cppvsdbg\"\n\t}\n}\n```\n\n## Parallel test jobs\n\nThe extension can run test jobs in parallel. The maximum number of jobs to run\nis the first non-zero value in the following order:\n\n- The `cmakeExplorer.parallelJobs` setting (see [Configuration](#configuration))\n- The `cmake.ctest.parallelJobs` then `cmake.parallelJobs` settings if the\n  [CMake Tools][cmake-tools] extension is installed\n- The number of processors on the machine\n\nA negative value will disable parallel execution.\n\nThe extension uses the native CTest parallel execution support (i.e. the\n`-j|--parallel` command-line option).\n\n## Troubleshooting\n\nFirst, make sure that CTest works from the command line. Some issues come from\nthe CTest configuration and not the extension itself. See issues #10 and #14 for\nexamples of such cases.\n\n### The Testing UI displays an error\n\nClicking on the error message in the Testing panel should open the log panel\nwith the output of the CTest command used by the extension to load the test\nlist.\n\n- `SyntaxError: Unexpected token T in JSON at position 0`\n\n    The extension requires CTest option `--show-only=json-v1` to load the test\n    list. This option was introduced with CMake version 3.14. Make sure to use a\n    version that supports this flag. See issue #2.\n\n- `Error: CMake cache file /path/to/project/${buildDirectory}/CMakeCache.txt does not exist`\n\n    The `cmakeExplorer.cmakeIntegration` flag is enabled by default. This adds\n    support for extra variables in other settings (See [Variable\n    substitution](#variable-substitution) for more info). If the extension is not\n    installed or active then these variables are not substituted. You can activate\n    the extension's log panel in the settings for more details.\n\n### The Testing UI shows no error but the test list is empty\n\nThe extension autodetects CMake build directories by finding all\n`CMakeCache.txt` in the workspace. Ensure you have at least one and run `ctest\n-C Debug` from there\n\n\u003c!-- Links --\u003e\n\n[vscode-testing]: https://code.visualstudio.com/docs/debugtest/testing\n[cmake-tools]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools\n[cmake]: https://cmake.org\n[cmake-set_tests_properties]: https://cmake.org/cmake/help/latest/command/set_tests_properties.html\n[cmake-test-properties]: https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#test-properties\n[cmake-environment]: https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT.html\n[re-groups]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Groups_and_Backreferences\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredericbonnet%2Fcmake-test-explorer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredericbonnet%2Fcmake-test-explorer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredericbonnet%2Fcmake-test-explorer/lists"}