Skip to content

Commit 576d25f

Browse files
committed
chore: run tests from toolkit/ instead of core/
1 parent 6f048d2 commit 576d25f

File tree

14 files changed

+93
-3657
lines changed

14 files changed

+93
-3657
lines changed

packages/core/package.json

Lines changed: 0 additions & 3640 deletions
Large diffs are not rendered by default.

packages/core/scripts/test/testInteg.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@
55

66
import { runToolkitTests } from './launchTestUtilities'
77
void (async () => {
8-
await runToolkitTests('integration', 'dist/src/testInteg/index.js')
8+
const relativeEntrypoint = process.argv[2]
9+
if (!relativeEntrypoint) {
10+
throw new Error('A path relative to core is required')
11+
}
12+
13+
const relativeWorkspaceFolder = process.argv[3]
14+
await runToolkitTests('integration', relativeEntrypoint, relativeWorkspaceFolder)
915
})()

packages/core/scripts/test/testWeb.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
import { runToolkitTests } from './launchTestUtilities'
77
void (async () => {
8-
await runToolkitTests('web', 'dist/src/testWeb/testRunnerWebCore.js')
8+
const relativeWorkspaceFolder = process.argv[2]
9+
10+
// Should be executed from a subproject/extension
11+
await runToolkitTests('web', '../core/dist/src/testWeb/testRunnerWebCore.js', relativeWorkspaceFolder)
912
})()

packages/core/src/shared/extensionUtilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const notInitialized = 'notInitialized'
2626

2727
function _isAmazonQ() {
2828
const id = globals.context.extension.id
29-
const isToolkit = id === VSCODE_EXTENSION_ID.awstoolkit || id === VSCODE_EXTENSION_ID.awstoolkitcore
29+
const isToolkit = id === VSCODE_EXTENSION_ID.awstoolkit
3030
const isQ = id === VSCODE_EXTENSION_ID.amazonq
3131
if (!isToolkit && !isQ) {
3232
throw Error(`unexpected extension id: ${id}`) // sanity check

packages/core/src/shared/extensions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { UriHandler } from './vscode/uriHandler'
1515
export const VSCODE_EXTENSION_ID = {
1616
awstoolkit: 'amazonwebservices.aws-toolkit-vscode',
1717
amazonq: 'amazonwebservices.amazon-q-vscode',
18-
awstoolkitcore: 'amazonwebservices.aws-core-vscode', // Core "extension" for tests - not a real extension.
1918
python: 'ms-python.python',
2019
// python depends on jupyter plugin
2120
jupyter: 'ms-toolsai.jupyter',

packages/core/src/test/shared/utilities/vscodeUtils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ describe('vscodeUtils', async function () {
1818

1919
assert.deepStrictEqual(vscodeUtil.isExtensionActive('invalid.extension'), false)
2020

21-
await vscodeUtil.activateExtension(VSCODE_EXTENSION_ID.awstoolkitcore, false)
22-
assert.deepStrictEqual(vscodeUtil.isExtensionActive(VSCODE_EXTENSION_ID.awstoolkitcore), true)
21+
await vscodeUtil.activateExtension(VSCODE_EXTENSION_ID.awstoolkit, false)
22+
assert.deepStrictEqual(vscodeUtil.isExtensionActive(VSCODE_EXTENSION_ID.awstoolkit), true)
2323
})
2424

2525
it('globDirPatterns()', async function () {

packages/core/src/test/testRunner.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ process.env.TZ = 'US/Pacific'
2222
export async function runTests(
2323
testFolder: string,
2424
initTests: string[] = [],
25-
extensionId: string = VSCODE_EXTENSION_ID.awstoolkitcore,
25+
extensionId: string = VSCODE_EXTENSION_ID.awstoolkit,
2626
testFiles?: string[]
2727
): Promise<void> {
2828
if (!process.env['AWS_TOOLKIT_AUTOMATION']) {
@@ -36,6 +36,9 @@ export async function runTests(
3636
}
3737

3838
/**
39+
* Retaining this because it may be relevant in the future for lib-only tests. For now,
40+
* all tests are ran from a subproject/extension.
41+
*
3942
* Node's `require` caches modules by case-sensitive paths, regardless of the underlying
4043
* file system. This is normally not a problem, but VS Code also happens to normalize paths
4144
* on Windows to use lowercase drive letters when using its bootstrap loader. This means
@@ -59,12 +62,7 @@ export async function runTests(
5962
* lower case module ids (since the tests live inside of core itself)
6063
*/
6164
const [drive, ...rest] = abs.split(':')
62-
return rest.length === 0
63-
? abs
64-
: [
65-
extensionId === VSCODE_EXTENSION_ID.awstoolkitcore ? drive.toLowerCase() : drive.toUpperCase(),
66-
...rest,
67-
].join(':')
65+
return rest.length === 0 ? abs : [drive.toUpperCase(), ...rest].join(':')
6866
}
6967

7068
const root = getRoot()
@@ -115,7 +113,7 @@ export async function runTests(
115113
})
116114

117115
function runMocha(files: string[]): Promise<void> {
118-
files.forEach((f) => mocha.addFile(path.resolve(dist, f)))
116+
files.forEach((f) => mocha.addFile(path.resolve(process.cwd(), f)))
119117
return new Promise<void>((resolve, reject) => {
120118
mocha.run((failures) => {
121119
if (failures > 0) {
@@ -139,7 +137,8 @@ export async function runTests(
139137
console.log('No test coverage found')
140138
}
141139
}
142-
const files = testFiles ?? (await glob(testFilePath ?? `**/${testFolder}/**/**.test.js`, { cwd: dist }))
140+
const files = testFiles ?? (await glob(testFilePath ?? `**/${testFolder}/**/**.test.js`))
141+
console.log(`@@@ files: ${files}`)
143142

144143
await runMocha(files)
145144
await writeCoverage()

packages/core/src/test/testUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export async function closeAllEditors(): Promise<void> {
373373
// - `vscode.OutputChannel` name prefixed with "extension-output". https://github.com/microsoft/vscode/issues/148993#issuecomment-1167654358
374374
// - `vscode.LogOutputChannel` name (created with `vscode.window.createOutputChannel(…,{log:true})`
375375
// Maybe we can close these with a command?
376-
const ignorePatterns = [/extension-output/, /tasks/, /amazonwebservices\.aws-core-vscode\./]
376+
const ignorePatterns = [/extension-output/, /tasks/, /nullExtensionDescription\./] // TODO: nullExtensionDescription may have side effects?
377377
const editors: vscode.TextEditor[] = []
378378

379379
const noVisibleEditor: boolean | undefined = await waitUntil(

packages/core/src/testWeb/testRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function gatherTestFiles() {
4646
* So this function ensures the extension has fully activated.
4747
*/
4848
async function activateToolkitExtension() {
49-
await vscode.extensions.getExtension(VSCODE_EXTENSION_ID.awstoolkitcore)?.activate()
49+
await vscode.extensions.getExtension(VSCODE_EXTENSION_ID.awstoolkit)?.activate()
5050
}
5151

5252
function runMochaTests(resolve: (value: void | PromiseLike<void>) => void, reject: (reason?: any) => void) {

packages/toolkit/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@
6363
"copyFiles": "ts-node ./scripts/build/copyFiles.ts",
6464
"clean": "ts-node ../../scripts/clean.ts dist/ LICENSE NOTICE quickStart*",
6565
"compile": "npm run clean && npm run buildScripts && webpack",
66+
"compileOnly": "tsc -p ./",
67+
"compileDev": "npm run compile -- --mode development",
68+
"testCompile": "npm run compileCore && npm run clean && npm run buildScripts && npm run compileOnly",
69+
"compileCore": "cd ../core && npm run compile",
70+
"test": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/test.ts dist/test/unit/index.js ../core/dist/src/testFixtures/workspaceFolder",
71+
"testInteg": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/testInteg.ts dist/test/integ/index.js ../core/dist/src/testFixtures/workspaceFolder",
72+
"testE2E": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/testE2E.ts dist/test/e2e/index.js ../core/dist/src/testFixtures/workspaceFolder",
73+
"testWeb": "npm run compileDev && c8 --allowExternal ts-node ../core/scripts/test/testWeb.ts ../core/dist/src/testFixtures/workspaceFolder",
6674
"webWatch": "npm run clean && npm run buildScripts && webpack --mode development --watch",
6775
"webCompile": "npm run clean && npm run buildScripts && webpack --config-name web",
6876
"webRun": "npx @vscode/test-web --open-devtools --browserOption=--disable-web-security --waitForDebugger=9222 --extensionDevelopmentPath=. .",

0 commit comments

Comments
 (0)