Skip to content

Commit 685924c

Browse files
committed
move tests into testPerf
1 parent dbefbf0 commit 685924c

File tree

7 files changed

+89
-79
lines changed

7 files changed

+89
-79
lines changed

packages/core/src/testInteg/shared/utilities/workspaceUtils.test.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import globals from '../../../shared/extensionGlobals'
1818
import { CodelensRootRegistry } from '../../../shared/fs/codelensRootRegistry'
1919
import { createTestWorkspace, createTestWorkspaceFolder, toFile } from '../../../test/testUtil'
2020
import sinon from 'sinon'
21-
import { performanceTest } from '../../../shared/performance/performance'
22-
import { randomUUID } from '../../../shared/crypto'
2321
import { fs } from '../../../shared'
2422

2523
describe('findParentProjectFile', async function () {
@@ -326,56 +324,6 @@ describe('collectFiles', function () {
326324
assert.deepStrictEqual(1, result.length)
327325
assert.deepStrictEqual('non-license.md', result[0].relativeFilePath)
328326
})
329-
330-
performanceTest(
331-
// collecting all files in the workspace and zipping them is pretty resource intensive
332-
{
333-
linux: {
334-
userCpuUsage: 85,
335-
heapTotal: 2,
336-
duration: 0.8,
337-
},
338-
},
339-
'calculate cpu and memory usage',
340-
function () {
341-
const totalFiles = 100
342-
return {
343-
setup: async () => {
344-
const workspace = await createTestWorkspaceFolder()
345-
346-
sinon.stub(vscode.workspace, 'workspaceFolders').value([workspace])
347-
348-
const fileContent = randomUUID()
349-
for (let x = 0; x < totalFiles; x++) {
350-
await toFile(fileContent, path.join(workspace.uri.fsPath, `file.${x}`))
351-
}
352-
353-
return {
354-
workspace,
355-
}
356-
},
357-
execute: async ({ workspace }: { workspace: vscode.WorkspaceFolder }) => {
358-
return {
359-
result: await collectFiles([workspace.uri.fsPath], [workspace], true),
360-
}
361-
},
362-
verify: (
363-
_: { workspace: vscode.WorkspaceFolder },
364-
{ result }: { result: Awaited<ReturnType<typeof collectFiles>> }
365-
) => {
366-
assert.deepStrictEqual(result.length, totalFiles)
367-
const sortedFiles = [...result].sort((a, b) => {
368-
const numA = parseInt(a.relativeFilePath.split('.')[1])
369-
const numB = parseInt(b.relativeFilePath.split('.')[1])
370-
return numA - numB
371-
})
372-
for (let x = 0; x < totalFiles; x++) {
373-
assert.deepStrictEqual(sortedFiles[x].relativeFilePath, `file.${x}`)
374-
}
375-
},
376-
}
377-
}
378-
)
379327
})
380328

381329
describe('getWorkspaceFoldersByPrefixes', function () {

packages/core/src/testInteg/buildIndex.test.ts renamed to packages/core/src/testInteg/testPerf/buildIndex.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { performanceTest } from '../shared/performance/performance'
6+
import { performanceTest } from '../../shared/performance/performance'
77
import * as sinon from 'sinon'
88
import * as vscode from 'vscode'
99
import assert from 'assert'
10-
import { LspClient, LspController } from '../amazonq'
10+
import { LspClient, LspController } from '../../amazonq'
1111
import { LanguageClient, ServerOptions } from 'vscode-languageclient'
12-
import { createTestWorkspace } from '../test/testUtil'
13-
import { GetUsageRequestType, IndexRequestType } from '../amazonq/lsp/types'
14-
import { getRandomString } from '../shared'
12+
import { createTestWorkspace } from '../../test/testUtil'
13+
import { GetUsageRequestType, IndexRequestType } from '../../amazonq/lsp/types'
14+
import { getRandomString } from '../../shared'
1515

1616
interface SetupResult {
1717
clientReqStub: sinon.SinonStub
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import assert from 'assert'
6+
import * as vscode from 'vscode'
7+
import * as sinon from 'sinon'
8+
import { performanceTest } from '../../shared/performance/performance'
9+
import { createTestWorkspaceFolder, toFile } from '../../test/testUtil'
10+
import path from 'path'
11+
import { randomUUID } from '../../shared'
12+
import { collectFiles } from '../../shared/utilities/workspaceUtils'
13+
14+
performanceTest(
15+
// collecting all files in the workspace and zipping them is pretty resource intensive
16+
{
17+
linux: {
18+
userCpuUsage: 85,
19+
heapTotal: 2,
20+
duration: 0.8,
21+
},
22+
},
23+
'calculate cpu and memory usage',
24+
function () {
25+
const totalFiles = 100
26+
return {
27+
setup: async () => {
28+
const workspace = await createTestWorkspaceFolder()
29+
30+
sinon.stub(vscode.workspace, 'workspaceFolders').value([workspace])
31+
32+
const fileContent = randomUUID()
33+
for (let x = 0; x < totalFiles; x++) {
34+
await toFile(fileContent, path.join(workspace.uri.fsPath, `file.${x}`))
35+
}
36+
37+
return {
38+
workspace,
39+
}
40+
},
41+
execute: async ({ workspace }: { workspace: vscode.WorkspaceFolder }) => {
42+
return {
43+
result: await collectFiles([workspace.uri.fsPath], [workspace], true),
44+
}
45+
},
46+
verify: (
47+
_: { workspace: vscode.WorkspaceFolder },
48+
{ result }: { result: Awaited<ReturnType<typeof collectFiles>> }
49+
) => {
50+
assert.deepStrictEqual(result.length, totalFiles)
51+
const sortedFiles = [...result].sort((a, b) => {
52+
const numA = parseInt(a.relativeFilePath.split('.')[1])
53+
const numB = parseInt(b.relativeFilePath.split('.')[1])
54+
return numA - numB
55+
})
56+
for (let x = 0; x < totalFiles; x++) {
57+
assert.deepStrictEqual(sortedFiles[x].relativeFilePath, `file.${x}`)
58+
}
59+
},
60+
}
61+
}
62+
)

packages/core/src/testInteg/startSecurityScan.test.ts renamed to packages/core/src/testInteg/testPerf/startSecurityScan.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
*/
55
import * as vscode from 'vscode'
66
import * as sinon from 'sinon'
7-
import * as startSecurityScan from '../codewhisperer/commands/startSecurityScan'
8-
import * as diagnosticsProvider from '../codewhisperer/service/diagnosticsProvider'
9-
import * as model from '../codewhisperer/models/model'
10-
import * as timeoutUtils from '../shared/utilities/timeoutUtils'
7+
import * as startSecurityScan from '../../codewhisperer/commands/startSecurityScan'
8+
import * as diagnosticsProvider from '../../codewhisperer/service/diagnosticsProvider'
9+
import * as model from '../../codewhisperer/models/model'
10+
import * as timeoutUtils from '../../shared/utilities/timeoutUtils'
1111
import assert from 'assert'
12-
import { SecurityPanelViewProvider } from '../codewhisperer/views/securityPanelViewProvider'
13-
import { FakeExtensionContext } from '../test/fakeExtensionContext'
12+
import { SecurityPanelViewProvider } from '../../codewhisperer/views/securityPanelViewProvider'
13+
import { FakeExtensionContext } from '../../test/fakeExtensionContext'
1414
import { join } from 'path'
1515
import {
1616
assertTelemetry,
1717
closeAllEditors,
1818
createTestWorkspaceFolder,
1919
getFetchStubWithResponse,
2020
toFile,
21-
} from '../test/testUtil'
22-
import { getTestWindow } from '../test/shared/vscode/window'
23-
import { SeverityLevel } from '../test/shared/vscode/message'
24-
import { CodeAnalysisScope } from '../codewhisperer'
25-
import { performanceTest } from '../shared/performance/performance'
26-
import { createClient } from '../test/codewhisperer/testUtil'
21+
} from '../../test/testUtil'
22+
import { getTestWindow } from '../../test/shared/vscode/window'
23+
import { SeverityLevel } from '../../test/shared/vscode/message'
24+
import { CodeAnalysisScope } from '../../codewhisperer'
25+
import { performanceTest } from '../../shared/performance/performance'
26+
import { createClient } from '../../test/codewhisperer/testUtil'
2727

2828
describe('startSecurityScanPerformanceTest', function () {
2929
let extensionContext: FakeExtensionContext

packages/core/src/testInteg/tryInstallLsp.test.ts renamed to packages/core/src/testInteg/testPerf/tryInstallLsp.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import sinon from 'sinon'
77
import { Content } from 'aws-sdk/clients/codecommit'
88
import AdmZip from 'adm-zip'
99
import path from 'path'
10-
import { LspController } from '../amazonq'
11-
import { fs, getRandomString, globals } from '../shared'
12-
import { createTestWorkspace } from '../test/testUtil'
13-
import { performanceTest } from '../shared/performance/performance'
10+
import { LspController } from '../../amazonq'
11+
import { fs, getRandomString, globals } from '../../shared'
12+
import { createTestWorkspace } from '../../test/testUtil'
13+
import { performanceTest } from '../../shared/performance/performance'
1414

1515
// fakeFileContent is matched to fakeQServerContent based on hash.
1616
const fakeHash = '4eb2865c8f40a322aa04e17d8d83bdaa605d6f1cb363af615240a5442a010e0aef66e21bcf4c88f20fabff06efe8a214'

packages/core/src/testInteg/zipcode.test.ts renamed to packages/core/src/testInteg/testPerf/zipcode.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
*/
55
import assert from 'assert'
66
import * as sinon from 'sinon'
7-
import { TransformByQState, ZipManifest } from '../codewhisperer'
8-
import { fs, getRandomString, globals } from '../shared'
9-
import { createTestWorkspace } from '../test/testUtil'
10-
import * as CodeWhispererConstants from '../codewhisperer/models/constants'
11-
import { performanceTest } from '../shared/performance/performance'
12-
import { zipCode } from '../codewhisperer/indexNode'
7+
import { TransformByQState, ZipManifest } from '../../codewhisperer'
8+
import { fs, getRandomString, globals } from '../../shared'
9+
import { createTestWorkspace } from '../../test/testUtil'
10+
import * as CodeWhispererConstants from '../../codewhisperer/models/constants'
11+
import { performanceTest } from '../../shared/performance/performance'
12+
import { zipCode } from '../../codewhisperer/indexNode'
1313

1414
interface SetupResult {
1515
tempDir: string

0 commit comments

Comments
 (0)