Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
9c1b1f2
Adds a new end to end test directory devoted to ctest tests
Nov 8, 2024
e101ea0
Fix non stopping breakpoints
Nov 8, 2024
072859f
Adds scripts entry for new end to end ctest
Nov 8, 2024
f562055
Adds configurations for new end to end ctest test
Nov 8, 2024
24c9e3f
Do not forbid test refreshing even in test mode
Nov 8, 2024
2e83da2
Fix end to end test devoted to ctest
hippo91 Nov 12, 2024
fa8a419
Test is functionnal when running through debug
hippo91 Nov 12, 2024
b4d2839
Add "allowParallelJobs" in the config
Nov 14, 2024
237079b
Removes useless files
Nov 14, 2024
6c4642f
Replaces TestCleanup target with simpler call in the teardown method
Nov 14, 2024
c8d5ce6
Add cmake.ctest.allowParallelJobs setting
Nov 14, 2024
4cfe9fc
Upgrade cmake minimum required version to avoid warnings
Nov 14, 2024
4a6202e
Sets up two tests. One with parallel jobs enabled and the other without
Nov 14, 2024
add157a
Remove useless file
Nov 14, 2024
14d7963
Adds two tests dealing with testSuiteDelimiter
Nov 14, 2024
8c057e3
Remove generated test file between each test
hippo91 Nov 14, 2024
9d90005
Do not delete file if it is not present
hippo91 Nov 14, 2024
5107e59
Fix test suite delimiter
Nov 15, 2024
cc818ae
Do not add a comma if no text is appended
Nov 15, 2024
f3dbbe2
Delete test file results before the test
Nov 15, 2024
3d9f137
Create cleanUpTestResultFiles to factorize code
Nov 15, 2024
838d8a2
Adds explicit message to failing assertions
Nov 15, 2024
cbe131c
Fix comment
Nov 15, 2024
2e7a64a
Generalize output writing
Nov 15, 2024
6c6290f
Protect empy successor when dealing with last element of the container
hippo91 Nov 16, 2024
7f05cff
Adds doc and format
hippo91 Nov 16, 2024
3858fff
Move suite initialization in the right method
hippo91 Nov 17, 2024
31119f2
Await for settings change promise
hippo91 Nov 17, 2024
6dec1a4
Set CMT_TESTING to one
hippo91 Nov 17, 2024
acfd55e
Restore previous state
hippo91 Nov 17, 2024
0306a82
Renames files and targets
hippo91 Nov 17, 2024
3c59270
Create a TestUtils lib to factorize code
hippo91 Nov 17, 2024
699c540
Start templating test file
hippo91 Nov 17, 2024
b8b7e45
Move cmake stuff in its own module
Nov 18, 2024
82c51b4
Adds doc
hippo91 Nov 18, 2024
006e9d6
Set tests definition in CMake presets
hippo91 Nov 18, 2024
cdc12ad
Renames preset
hippo91 Nov 18, 2024
8084838
Remove generated test from git
Nov 19, 2024
bf7d481
Fix generate_test_source_file function and return value
Nov 19, 2024
b8f085a
Introduces use of common directory to store test result
Nov 19, 2024
8945d0d
Defines common tests directory in cmake cache variables
Nov 19, 2024
b2909a2
Add and fix doc. Renames variable.
Nov 19, 2024
d65b685
First ry to retrieve CMakePresets name in the test
Nov 21, 2024
465090e
Remove tmp test dir, its location being read from CMakePresets.
hippo91 Nov 21, 2024
d173bb5
Reword test labels
hippo91 Nov 21, 2024
28ee508
Format
hippo91 Nov 21, 2024
aa5d49e
Turns method into free function to be reused in other test suites
hippo91 Nov 21, 2024
f25e4c6
Removes unused import
hippo91 Nov 21, 2024
164b2ac
Adds another test suite to check test failure detection
hippo91 Nov 21, 2024
b1e0b35
Typo
hippo91 Nov 23, 2024
5a1234f
Adds comments
hippo91 Nov 23, 2024
f89b166
Factorize code
hippo91 Nov 23, 2024
1bb015b
Add newline at eof
hippo91 Nov 23, 2024
8fcc6be
Typos
hippo91 Nov 23, 2024
f6eeb39
Adds suite test to check when all tests fail
hippo91 Nov 23, 2024
fc734a6
Adds doc. Removes comment
hippo91 Nov 24, 2024
f904fcf
Moves test env initialization into commonSetup method to avoid code d…
hippo91 Nov 24, 2024
ad54d5e
Adds doc
hippo91 Nov 24, 2024
648eea6
Remove dead code
hippo91 Nov 24, 2024
84f9ec7
Merge branch 'main' into add_end_to_end_ctest_tests
gcampbell-msft Mar 7, 2025
f8f08cb
Adds endToEndTestsSingleRootCTest to the list of tests to run in the …
hippo91 Mar 8, 2025
5e3a173
Remove launch configuration modification that was not made on purpose
hippo91 Mar 8, 2025
4be0468
Enable test explorer for those test suites
hippo91 Mar 22, 2025
da55531
Keeping integrity of the return code as suggested in the review comments
hippo91 Mar 22, 2025
84afd09
Takes into account code review suggestions
hippo91 Mar 22, 2025
ca9f62f
Specify compilers for linux and windows systems.
hippo91 Mar 22, 2025
b1fc68c
Select the preset according to the OS type
hippo91 Mar 22, 2025
a491c46
Updated Issue Template Selection (#4335)
snehara99 Mar 7, 2025
f6c563b
Fix 3232 (#4223)
hippo91 Mar 10, 2025
b392d58
feat: add `cmake.ctest.debugLaunchTarget` (#4273)
Nerixyz Mar 10, 2025
63357d2
fix(ctest): don't require backtrace in presence of DEF_SOURCE_LINE (#…
rjaegers Mar 10, 2025
cec677d
Fix lowercase include paths on Mac (#4325)
tringenbach Mar 10, 2025
ae4dbf1
Fix gnuld error parsing false positive on make errors, false negative…
0xemgy Mar 10, 2025
7f514a2
Dev/snehara/update readme (#4338)
snehara99 Mar 10, 2025
937d162
fix getProjectForFolder (#4348)
gcampbell-msft Mar 11, 2025
c2579d7
Don't require LCOV to be found in test project (#4351)
TSonono Mar 12, 2025
f0fb4e8
Update README.md (#4350)
snehara99 Mar 12, 2025
faa7327
be more explicit in what we check (#4352)
gcampbell-msft Mar 12, 2025
8d6a836
Localization - Translated Strings (#4344)
gcampbell-msft Mar 13, 2025
1888d74
Localization - Translated Strings (#4353)
gcampbell-msft Mar 24, 2025
eaa4ff0
Merge branch 'main' into add_end_to_end_ctest_tests
hippo91 Apr 12, 2025
c197f40
Merge branch 'main' into add_end_to_end_ctest_tests
hippo91 Apr 17, 2025
46ba27e
Changes the location of temp directory holding the tests (TESTS_DIR).
hippo91 Apr 17, 2025
6be0025
Remove useless CMAKE variable
hippo91 Apr 17, 2025
b998ceb
Merge branch 'main' into add_end_to_end_ctest_tests
gcampbell-msft Jun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci-main-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ jobs:
with:
run: yarn endToEndTestsSingleRoot

- name: Run single root test for ctest
uses: GabrielBB/[email protected]
with:
run: yarn endToEndTestsSingleRootCTest


- name: Run multi root test
uses: GabrielBB/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-main-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
- name: Run single root test
run: yarn endToEndTestsSingleRoot

- name: Run single root test for ctest
run: yarn endToEndTestsSingleRootCTest

- name: Run multi root test
run: yarn endToEndTestsMultiRoot

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-main.win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ jobs:
- name: Run single root test
run: yarn endToEndTestsSingleRoot

- name: Run single root test for ctest
run: yarn endToEndTestsSingleRootCTest

- name: Run multi root test
run: yarn endToEndTestsMultiRoot

Expand Down
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@
"TEST_FILTER": ".*"
},
},
{
"name": "Run single-root-ctest Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/test/end-to-end-tests/single-root-ctest/project-folder",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/end-to-end-tests/single-root-ctest/index"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/dist/**/*.js",
"${workspaceFolder}/out/*",
"${workspaceFolder}/out/src/**",
"${workspaceFolder}/out/test/*",
"${workspaceFolder}/out/test/end-to-end-tests/single-root-ctest/*",
"${workspaceFolder}/out/test/end-to-end-tests/single-root-ctest/test/*"
],
"preLaunchTask": "Pretest",
"env": {
"CMT_TESTING": "1",
"CMT_QUIET_CONSOLE": "1",
"TEST_FILTER": ".*"
},
},
{
"name": "Run multi-root-UI Tests",
"type": "extensionHost",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3793,6 +3793,7 @@
"integrationTests": "yarn run pretest && node ./out/test/integration-tests/runTest.js",
"endToEndTestsSuccessfulBuild": "yarn run pretest && node ./out/test/end-to-end-tests/successful-build/runTest.js",
"endToEndTestsSingleRoot": "yarn run pretest && node ./out/test/end-to-end-tests/single-root-UI/runTest.js",
"endToEndTestsSingleRootCTest": "yarn run pretest && node ./out/test/end-to-end-tests/single-root-ctest/runTest.js",
"endToEndTestsMultiRoot": "yarn run pretest && node ./out/test/end-to-end-tests/multi-root-UI/runTest.js",
"backendTests": "node ./node_modules/mocha/bin/_mocha -u tdd --timeout 999999 --colors -r ts-node/register -r tsconfig-paths/register ./test/unit-tests/backend/**/*.test.ts",
"build-product-icon-font": "yarn --cwd ./tools/product-icon-font-generator/ install && yarn --cwd ./tools/product-icon-font-generator/ build && node ./tools/product-icon-font-generator/dist/index.js --source-directory ./res/product-icons/ --output-directory ./res/ --woff2"
Expand Down
2 changes: 1 addition & 1 deletion src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2391,7 +2391,7 @@ export class CMakeProject {
async ctest(fromWorkflow: boolean = false): Promise<number> {
const drv = await this.preTest(fromWorkflow);
const retc = await this.cTestController.runCTest(drv);
return (retc) ? 0 : -1;
return retc;
}

async cpack(fromWorkflow: boolean = false): Promise<number> {
Expand Down
54 changes: 54 additions & 0 deletions test/end-to-end-tests/single-root-ctest/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// eslint-disable-next-line import/no-unassigned-import
import 'module-alias/register';

import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
import { Logger } from '@cmt/logging';

export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});

const testsRoot = __dirname;

return new Promise((c, e) => {
glob('**/*.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}

// Add files to the test suite
const regex = process.env.TEST_FILTER ? new RegExp(process.env.TEST_FILTER) : /.*/;
files.forEach(f => {
if (regex.test(f)) {
mocha.addFile(path.resolve(testsRoot, f));
}
});

try {
// Run the mocha test
mocha.timeout(100000);

// Log the name of each test before it starts.
const beforeEach: Mocha.Func = function (this: Mocha.Context, done: Mocha.Done) {
Logger.logTestName(this.currentTest?.parent?.title, this.currentTest?.title);
done();
};
mocha.rootHooks({beforeEach});
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
e(err);
}
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cmake.buildDirectory": "${workspaceFolder}/build",
"cmake.useCMakePresets": "always",
"cmake.configureOnOpen": false,
"cmake.ctest.allowParallelJobs": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.6.0)
project(TestCTestProcess VERSION 0.1.0)

add_library(TestUtils SHARED)
target_sources(TestUtils PRIVATE test_utils.cpp)
target_include_directories(TestUtils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(TestUtils PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED
ON)

set(TESTS_DIR
""
CACHE STRING "Directory where the files generated by tests will be written")
# Will generate a file get_test_dir.h with the content of get_test_dir.h.in It's
# goal is to provide a function that returns the directory where the tests will
# be executed
configure_file("get_test_dir.h.in" "get_test_dir.h" @ONLY)
add_library(GetTestDir INTERFACE)
target_include_directories(GetTestDir INTERFACE ${CMAKE_CURRENT_BINARY_DIR})

# Adds an executable that will generate an output file by concatenating the
# content of each file in the test directory
add_executable(GenerateOutputFile generate_output_file.cpp)
target_link_libraries(GenerateOutputFile PRIVATE GetTestDir)
set_target_properties(GenerateOutputFile PROPERTIES CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON)

enable_testing()

# The generation of json readable output file must occur after each test run
# Declares a fixture that will be executed after each test run
add_test(NAME "Generate_Output_File" COMMAND GenerateOutputFile)
set_tests_properties("Generate_Output_File" PROPERTIES FIXTURES_CLEANUP GENOUT)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(RegisterTest)

set(TESTS_OUTPUT_FILES
""
CACHE STRING "Output files generated by tests")
set(TESTS_NAMES
""
CACHE STRING "Names of the tests")
set(TESTS_SUCCESS
""
CACHE BOOL "Success of the tests")

register_tests(
TEST_DIRECTORY
${TESTS_DIR}
TEST_NAME_LIST
${TESTS_NAMES}
TEST_OUTPUT_FILE_LIST
${TESTS_OUTPUT_FILES}
TEST_SUCCESS_LIST
${TESTS_SUCCESS})
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"version": 9,
"configurePresets": [
{
"name": "LinuxBase",
"description": "Sets compilers for linux based systems",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${workspaceFolder}/build",
"cacheVariables": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ensure that we define the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER, depending on what OS this is run on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gcampbell-msft i added hidden configure preset that hold compiler specifications for linux and windows systems. These presets are then mixed up with those setting up the tests to have all cases covered.

"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "WindowsBase",
"description": "Sets compilers for linux based systems",
"hidden": true,
"generator": "Visual Studio 16 2019",
"binaryDir": "${workspaceFolder}/build",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
}
},
{
"name": "2Successes",
"description": "Configures 2 tests that end successfully",
"hidden": true,
"cacheVariables": {
"TESTS_DIR": "${workspaceFolder}/build/vscode-cmake-tools-tests",
"TESTS_OUTPUT_FILES": "test_a.txt;test_b.txt",
"TESTS_NAMES": "Suite1.TestA;Suite2.TestB",
"TESTS_SUCCESS": "true;true"
}
},
{
"name": "2Successes1Failure",
"description": "Configures 2 tests that end successfully and 1 that fails",
"hidden": true,
"cacheVariables": {
"TESTS_DIR": "${workspaceFolder}/build/vscode-cmake-tools-tests",
"TESTS_OUTPUT_FILES": "test_a.txt;test_b.txt;test_c.txt",
"TESTS_NAMES": "Suite1.TestA;Suite2.TestB;Suite2.TestC",
"TESTS_SUCCESS": "true;false;true"
}
},
{
"name": "3Failures",
"description": "Configures 3 tests that fail",
"hidden": true,
"cacheVariables": {
"TESTS_DIR": "${workspaceFolder}/build/vscode-cmake-tools-tests",
"TESTS_OUTPUT_FILES": "test_a.txt;test_b.txt;test_c.txt",
"TESTS_NAMES": "Suite1.TestA;Suite2.TestB;Suite2.TestC",
"TESTS_SUCCESS": "false;false;false"
}
},
{
"name": "Linux-2Successes",
"inherits": ["LinuxBase", "2Successes"],
"description": "Configures 2 tests that end successfully under linux"
},
{
"name": "Linux-2Successes1Failure",
"inherits": ["LinuxBase", "2Successes1Failure"],
"description": "Configures 2 tests that end successfully and 1 that fails under linux"
},
{
"name": "Linux-3Failures",
"inherits": ["LinuxBase", "3Failures"],
"description": "Configures 3 tests that fail under linux"
},
{
"name": "Windows-2Successes",
"inherits": ["WindowsBase", "2Successes"],
"description": "Configures 2 tests that end successfully under windows"
},
{
"name": "Windows-2Successes1Failure",
"inherits": ["WindowsBase", "2Successes1Failure"],
"description": "Configures 2 tests that end successfully and 1 that fails under windows"
},
{
"name": "Windows-3Failures",
"inherits": ["WindowsBase", "3Failures"],
"description": "Configures 3 tests that fail under windows"
}
]
}
Loading
Loading