-
Notifications
You must be signed in to change notification settings - Fork 11
qt-cpp: Add dedicated test infrastructure for CMake Presets #290
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
OrkunTokdemir
wants to merge
5
commits into
qt-labs:dev
Choose a base branch
from
OrkunTokdemir:orkun_presets_test_12_10_2025
base: dev
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
5 commits
Select commit
Hold shift + click to select a range
4778d1e
qt-qml: qt-cpp: qt-lib: Add support for installing pre-release extens…
OrkunTokdemir b1236c2
qt-cpp: Add dedicated test infrastructure for CMake Presets
OrkunTokdemir 0448872
fixup! qt-qml: qt-cpp: qt-lib: Add support for installing pre-release…
OrkunTokdemir 0a70c24
qt-cpp:presets-test: Add CMakeConfigurator helper for test cleanup
OrkunTokdemir f8ec7be
qt-cpp:build-test: Use CMakeConfigrator for CMake settings
OrkunTokdemir 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
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,70 @@ | ||
| // Copyright (C) 2025 The Qt Company Ltd. | ||
| // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only | ||
|
|
||
lugerard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import * as path from 'path'; | ||
| import * as os from 'os'; | ||
| import * as fsp from 'fs/promises'; | ||
|
|
||
| import { downloadAndUnzipVSCode, runTests } from '@vscode/test-electron'; | ||
|
|
||
| import { | ||
| setupTestInfrastructure, | ||
| setupVSCodeSettings, | ||
| installRequiredExtensions | ||
| } from './runTestHelper.mjs'; | ||
| import { ExtensionInstallInfo } from 'qt-lib/src/test-vscode-install.ts'; | ||
|
|
||
| async function main() { | ||
| try { | ||
| // The folder containing the Extension Manifest package.json | ||
| // Passed to --extensionDevelopmentPath | ||
| const extensionDevelopmentPath = path.resolve(__dirname, '../../'); | ||
|
|
||
| // The path to the extension test script | ||
| // Passed to --extensionTestsPath | ||
| const extensionTestsPath = path.resolve(__dirname, './suite/index-presets'); | ||
|
|
||
| const vscodeExecutablePath = await downloadAndUnzipVSCode(); | ||
|
|
||
| const { qtRoot, localQtCoreVsix, cli, args, userDataDir } = | ||
| await setupTestInfrastructure(vscodeExecutablePath); | ||
|
|
||
| setupVSCodeSettings(userDataDir, qtRoot, { | ||
| 'cmake.configureOnOpen': false | ||
| }); | ||
| const extensions: ExtensionInstallInfo[] = [ | ||
| { idOrVsix: 'ms-vscode.cmake-tools', preRelease: true }, | ||
| { idOrVsix: localQtCoreVsix } | ||
| ]; | ||
| installRequiredExtensions(cli, args, extensions); | ||
|
|
||
| // The workspace folder we want to open | ||
| const projectDir = path.resolve(__dirname, '../../test/projectFolder'); | ||
| console.log('[runTest] Using project dir:', projectDir); | ||
| const tmpWs = await fsp.mkdtemp(path.join(os.tmpdir(), 'qt-cpp-ws-')); | ||
| const tmpProject = path.join(tmpWs, 'project'); | ||
| await fsp.mkdir(tmpProject, { recursive: true }); | ||
| // Node 16+: recursive copy | ||
| await fsp.cp(projectDir, tmpProject, { recursive: true }); | ||
| console.log('[runTest] Copied project to temp dir:', tmpProject); | ||
|
|
||
| // Run the integration tests (no need to pass launchArgs; we reused the same dirs) | ||
| try { | ||
| await runTests({ | ||
| launchArgs: [tmpProject, '--disable-workspace-trust'], | ||
| extensionDevelopmentPath, | ||
| extensionTestsPath | ||
| }); | ||
| } finally { | ||
| try { | ||
| await fsp.rm(tmpWs, { recursive: true, force: true }); | ||
| } catch {} | ||
| } | ||
| } catch (e: Error | unknown) { | ||
| console.error('Failed to run tests'); | ||
| console.error(e); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| main(); | ||
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,33 @@ | ||
| // Copyright (C) 2025 The Qt Company Ltd. | ||
| // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only | ||
|
|
||
| // This index is used exclusively for CMake Presets tests. | ||
| // It should only include presets.test.mts to test CMake Presets functionality | ||
| // with the prerelease version of CMake Tools. | ||
|
|
||
| import * as path from 'path'; | ||
| import Mocha from 'mocha'; | ||
| import * as glob from 'glob'; | ||
|
|
||
| export function run(): Promise<void> { | ||
| const mocha = new Mocha({ ui: 'bdd', color: true }); | ||
|
|
||
| const testsRoot = path.resolve(__dirname); | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| // Only include the presets test file that esbuild outputs | ||
| const g = new glob.Glob('presets.test.js', { cwd: testsRoot }); | ||
|
|
||
| g.stream() | ||
| .on('data', (file) => mocha.addFile(path.resolve(testsRoot, file))) | ||
| .on('error', (err) => | ||
| reject(err instanceof Error ? err : new Error(String(err))) | ||
| ) | ||
| .on('end', () => { | ||
| mocha.timeout(150_000); | ||
| mocha.run((failures) => | ||
| failures ? reject(new Error(`${failures} tests failed.`)) : resolve() | ||
| ); | ||
| }); | ||
| }); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.