-
Notifications
You must be signed in to change notification settings - Fork 509
Add end to end test devoted to ctest #4186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hippo91
wants to merge
85
commits into
microsoft:main
Choose a base branch
from
hippo91:add_end_to_end_ctest_tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
e101ea0
Fix non stopping breakpoints
072859f
Adds scripts entry for new end to end ctest
f562055
Adds configurations for new end to end ctest test
24c9e3f
Do not forbid test refreshing even in test mode
2e83da2
Fix end to end test devoted to ctest
hippo91 fa8a419
Test is functionnal when running through debug
hippo91 b4d2839
Add "allowParallelJobs" in the config
237079b
Removes useless files
6c4642f
Replaces TestCleanup target with simpler call in the teardown method
c8d5ce6
Add cmake.ctest.allowParallelJobs setting
4cfe9fc
Upgrade cmake minimum required version to avoid warnings
4a6202e
Sets up two tests. One with parallel jobs enabled and the other without
add157a
Remove useless file
14d7963
Adds two tests dealing with testSuiteDelimiter
8c057e3
Remove generated test file between each test
hippo91 9d90005
Do not delete file if it is not present
hippo91 5107e59
Fix test suite delimiter
cc818ae
Do not add a comma if no text is appended
f3dbbe2
Delete test file results before the test
3d9f137
Create cleanUpTestResultFiles to factorize code
838d8a2
Adds explicit message to failing assertions
cbe131c
Fix comment
2e7a64a
Generalize output writing
6c6290f
Protect empy successor when dealing with last element of the container
hippo91 7f05cff
Adds doc and format
hippo91 3858fff
Move suite initialization in the right method
hippo91 31119f2
Await for settings change promise
hippo91 6dec1a4
Set CMT_TESTING to one
hippo91 acfd55e
Restore previous state
hippo91 0306a82
Renames files and targets
hippo91 3c59270
Create a TestUtils lib to factorize code
hippo91 699c540
Start templating test file
hippo91 b8b7e45
Move cmake stuff in its own module
82c51b4
Adds doc
hippo91 006e9d6
Set tests definition in CMake presets
hippo91 cdc12ad
Renames preset
hippo91 8084838
Remove generated test from git
bf7d481
Fix generate_test_source_file function and return value
b8f085a
Introduces use of common directory to store test result
8945d0d
Defines common tests directory in cmake cache variables
b2909a2
Add and fix doc. Renames variable.
d65b685
First ry to retrieve CMakePresets name in the test
465090e
Remove tmp test dir, its location being read from CMakePresets.
hippo91 d173bb5
Reword test labels
hippo91 28ee508
Format
hippo91 aa5d49e
Turns method into free function to be reused in other test suites
hippo91 f25e4c6
Removes unused import
hippo91 164b2ac
Adds another test suite to check test failure detection
hippo91 b1e0b35
Typo
hippo91 5a1234f
Adds comments
hippo91 f89b166
Factorize code
hippo91 1bb015b
Add newline at eof
hippo91 8fcc6be
Typos
hippo91 f6eeb39
Adds suite test to check when all tests fail
hippo91 fc734a6
Adds doc. Removes comment
hippo91 f904fcf
Moves test env initialization into commonSetup method to avoid code d…
hippo91 ad54d5e
Adds doc
hippo91 648eea6
Remove dead code
hippo91 84f9ec7
Merge branch 'main' into add_end_to_end_ctest_tests
gcampbell-msft f8f08cb
Adds endToEndTestsSingleRootCTest to the list of tests to run in the …
hippo91 5e3a173
Remove launch configuration modification that was not made on purpose
hippo91 4be0468
Enable test explorer for those test suites
hippo91 da55531
Keeping integrity of the return code as suggested in the review comments
hippo91 84afd09
Takes into account code review suggestions
hippo91 ca9f62f
Specify compilers for linux and windows systems.
hippo91 b1fc68c
Select the preset according to the OS type
hippo91 a491c46
Updated Issue Template Selection (#4335)
snehara99 f6c563b
Fix 3232 (#4223)
hippo91 b392d58
feat: add `cmake.ctest.debugLaunchTarget` (#4273)
Nerixyz 63357d2
fix(ctest): don't require backtrace in presence of DEF_SOURCE_LINE (#…
rjaegers cec677d
Fix lowercase include paths on Mac (#4325)
tringenbach ae4dbf1
Fix gnuld error parsing false positive on make errors, false negative…
0xemgy 7f514a2
Dev/snehara/update readme (#4338)
snehara99 937d162
fix getProjectForFolder (#4348)
gcampbell-msft c2579d7
Don't require LCOV to be found in test project (#4351)
TSonono f0fb4e8
Update README.md (#4350)
snehara99 faa7327
be more explicit in what we check (#4352)
gcampbell-msft 8d6a836
Localization - Translated Strings (#4344)
gcampbell-msft 1888d74
Localization - Translated Strings (#4353)
gcampbell-msft eaa4ff0
Merge branch 'main' into add_end_to_end_ctest_tests
hippo91 c197f40
Merge branch 'main' into add_end_to_end_ctest_tests
hippo91 46ba27e
Changes the location of temp directory holding the tests (TESTS_DIR).
hippo91 6be0025
Remove useless CMAKE variable
hippo91 b998ceb
Merge branch 'main' into add_end_to_end_ctest_tests
gcampbell-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| }); | ||
| }); | ||
| } |
6 changes: 6 additions & 0 deletions
6
test/end-to-end-tests/single-root-ctest/project-folder/.vscode/settings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
55 changes: 55 additions & 0 deletions
55
test/end-to-end-tests/single-root-ctest/project-folder/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}) |
91 changes: 91 additions & 0 deletions
91
test/end-to-end-tests/single-root-ctest/project-folder/CMakePresets.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": { | ||
| "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" | ||
| } | ||
| ] | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.