Skip to content

Commit ae56418

Browse files
eleanorjboydCopilot
andcommitted
Expand compact discovery payload in symlink end-to-end tests
The tests stubbed resolveDiscovery to capture the raw payload, but the compact discovery payload returns paths relative to pathBase. Expand the payload before asserting so the symlink-path assertions still hold against the absolute symlink path produced by expansion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 314d120 commit ae56418

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

src/test/testing/common/testingAdapter.test.ts

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { PytestTestExecutionAdapter } from '../../../client/testing/testControll
2323
import { UnittestTestDiscoveryAdapter } from '../../../client/testing/testController/unittest/testDiscoveryAdapter';
2424
import { UnittestTestExecutionAdapter } from '../../../client/testing/testController/unittest/testExecutionAdapter';
2525
import { PythonResultResolver } from '../../../client/testing/testController/common/resultResolver';
26+
import { expandCompactDiscoveryPayload } from '../../../client/testing/testController/common/testDiscoveryHandler';
2627
import { TestProvider } from '../../../client/testing/types';
2728
import { PYTEST_PROVIDER, UNITTEST_PROVIDER } from '../../../client/testing/common/constants';
2829
import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types';
@@ -310,16 +311,15 @@ suite('End to End Tests: test adapters', () => {
310311
// 3. Confirm tests are found
311312
assert.ok(actualData.tests, 'Expected tests to be present');
312313
// 4. Confirm that the cwd returned is the symlink path and the test's path is also using the symlink as the root
314+
const expandedTests = (expandCompactDiscoveryPayload(actualData as any).tests as unknown) as {
315+
children: { path: string }[];
316+
};
313317
if (process.platform === 'win32') {
314318
// covert string to lowercase for windows as the path is case insensitive
315319
traceLog('windows machine detected, converting path to lowercase for comparison');
316320
const a = actualData.cwd.toLowerCase();
317321
const b = filePath.toLowerCase();
318-
const testSimpleActual = (actualData.tests as {
319-
children: {
320-
path: string;
321-
}[];
322-
}).children[0].path.toLowerCase();
322+
const testSimpleActual = expandedTests.children[0].path.toLowerCase();
323323
const testSimpleExpected = filePath.toLowerCase();
324324
assert.strictEqual(a, b, `Expected cwd to be the symlink path actual: ${a} expected: ${b}`);
325325
assert.strictEqual(
@@ -334,11 +334,7 @@ suite('End to End Tests: test adapters', () => {
334334
'Expected cwd to be the symlink path, check for non-windows machines',
335335
);
336336
assert.strictEqual(
337-
(actualData.tests as {
338-
children: {
339-
path: string;
340-
}[];
341-
}).children[0].path,
337+
expandedTests.children[0].path,
342338
filePath,
343339
'Expected test path to be the symlink path, check for non windows machines',
344340
);
@@ -393,16 +389,15 @@ suite('End to End Tests: test adapters', () => {
393389
// 3. Confirm tests are found
394390
assert.ok(actualData.tests, 'Expected tests to be present');
395391
// 4. Confirm that the cwd returned is the symlink path and the test's path is also using the symlink as the root
392+
const expandedTests = (expandCompactDiscoveryPayload(actualData as any).tests as unknown) as {
393+
children: { path: string }[];
394+
};
396395
if (process.platform === 'win32') {
397396
// covert string to lowercase for windows as the path is case insensitive
398397
traceLog('windows machine detected, converting path to lowercase for comparison');
399398
const a = actualData.cwd.toLowerCase();
400399
const b = rootPathDiscoverySymlink.toLowerCase();
401-
const testSimpleActual = (actualData.tests as {
402-
children: {
403-
path: string;
404-
}[];
405-
}).children[0].path.toLowerCase();
400+
const testSimpleActual = expandedTests.children[0].path.toLowerCase();
406401
const testSimpleExpected = testSimpleSymlinkPath.toLowerCase();
407402
assert.strictEqual(a, b, `Expected cwd to be the symlink path actual: ${a} expected: ${b}`);
408403
assert.strictEqual(
@@ -417,11 +412,7 @@ suite('End to End Tests: test adapters', () => {
417412
'Expected cwd to be the symlink path, check for non-windows machines',
418413
);
419414
assert.strictEqual(
420-
(actualData.tests as {
421-
children: {
422-
path: string;
423-
}[];
424-
}).children[0].path,
415+
expandedTests.children[0].path,
425416
testSimpleSymlinkPath,
426417
'Expected test path to be the symlink path, check for non windows machines',
427418
);

0 commit comments

Comments
 (0)