Skip to content

Commit ede8bcf

Browse files
committed
add conditional for symlink and reset setting args
1 parent 790b821 commit ede8bcf

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,17 @@ suite('End to End Tests: test adapters', () => {
7272
// create symlink for specific symlink test
7373
const target = rootPathSmallWorkspace;
7474
const dest = rootPathDiscoverySymlink;
75-
fs.symlink(target, dest, 'dir', (err) => {
76-
if (err) {
77-
console.error(err);
78-
} else {
79-
console.log('Symlink created successfully for end to end tests.');
80-
}
81-
});
75+
try {
76+
fs.symlink(target, dest, 'dir', (err) => {
77+
if (err) {
78+
console.error(err);
79+
} else {
80+
console.log('Symlink created successfully for end to end tests.');
81+
}
82+
});
83+
} catch (err) {
84+
console.error(err);
85+
}
8286
});
8387

8488
setup(async () => {
@@ -117,13 +121,17 @@ suite('End to End Tests: test adapters', () => {
117121
suiteTeardown(async () => {
118122
// remove symlink
119123
const dest = rootPathDiscoverySymlink;
120-
fs.unlink(dest, (err) => {
121-
if (err) {
122-
console.error(err);
123-
} else {
124-
console.log('Symlink removed successfully after tests.');
125-
}
126-
});
124+
if (fs.existsSync(dest)) {
125+
fs.unlink(dest, (err) => {
126+
if (err) {
127+
console.error(err);
128+
} else {
129+
console.log('Symlink removed successfully after tests.');
130+
}
131+
});
132+
} else {
133+
console.log('Symlink was not found to remove after tests, exiting successfully');
134+
}
127135
});
128136
test('unittest discovery adapter small workspace', async () => {
129137
// result resolver and saved data for assertions
@@ -293,6 +301,7 @@ suite('End to End Tests: test adapters', () => {
293301
resultResolver,
294302
envVarsService,
295303
);
304+
configService.getSettings(workspaceUri).testing.pytestArgs = [];
296305

297306
await discoveryAdapter.discoverTests(workspaceUri, pythonExecFactory).finally(() => {
298307
// verification after discovery is complete
@@ -372,6 +381,7 @@ suite('End to End Tests: test adapters', () => {
372381

373382
// set workspace to test workspace folder
374383
workspaceUri = Uri.parse(rootPathLargeWorkspace);
384+
configService.getSettings(workspaceUri).testing.pytestArgs = [];
375385

376386
await discoveryAdapter.discoverTests(workspaceUri, pythonExecFactory).finally(() => {
377387
// verification after discovery is complete
@@ -558,6 +568,7 @@ suite('End to End Tests: test adapters', () => {
558568
};
559569
// set workspace to test workspace folder
560570
workspaceUri = Uri.parse(rootPathSmallWorkspace);
571+
configService.getSettings(workspaceUri).testing.pytestArgs = [];
561572

562573
// run pytest execution
563574
const executionAdapter = new PytestTestExecutionAdapter(
@@ -648,6 +659,7 @@ suite('End to End Tests: test adapters', () => {
648659

649660
// set workspace to test workspace folder
650661
workspaceUri = Uri.parse(rootPathLargeWorkspace);
662+
configService.getSettings(workspaceUri).testing.pytestArgs = [];
651663

652664
// generate list of test_ids
653665
const testIds: string[] = [];
@@ -728,6 +740,7 @@ suite('End to End Tests: test adapters', () => {
728740

729741
// set workspace to test workspace folder
730742
workspaceUri = Uri.parse(rootPathDiscoveryErrorWorkspace);
743+
configService.getSettings(workspaceUri).testing.unittestArgs = ['-s', '.', '-p', '*test*.py'];
731744

732745
const discoveryAdapter = new UnittestTestDiscoveryAdapter(
733746
pythonTestServer,
@@ -799,6 +812,8 @@ suite('End to End Tests: test adapters', () => {
799812

800813
// set workspace to test workspace folder
801814
workspaceUri = Uri.parse(rootPathDiscoveryErrorWorkspace);
815+
configService.getSettings(workspaceUri).testing.pytestArgs = [];
816+
802817
await discoveryAdapter.discoverTests(workspaceUri, pythonExecFactory).finally(() => {
803818
// verification after discovery is complete
804819
assert.ok(
@@ -860,6 +875,7 @@ suite('End to End Tests: test adapters', () => {
860875

861876
// set workspace to test workspace folder
862877
workspaceUri = Uri.parse(rootPathErrorWorkspace);
878+
configService.getSettings(workspaceUri).testing.unittestArgs = ['-s', '.', '-p', '*test*.py'];
863879

864880
// run pytest execution
865881
const executionAdapter = new UnittestTestExecutionAdapter(
@@ -921,6 +937,7 @@ suite('End to End Tests: test adapters', () => {
921937

922938
// set workspace to test workspace folder
923939
workspaceUri = Uri.parse(rootPathErrorWorkspace);
940+
configService.getSettings(workspaceUri).testing.pytestArgs = [];
924941

925942
// run pytest execution
926943
const executionAdapter = new PytestTestExecutionAdapter(

0 commit comments

Comments
 (0)