Skip to content

Commit 8e4f43d

Browse files
committed
fixed tests failing on windows
1 parent 4ebfa9b commit 8e4f43d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

vscode/src/test/integration/suite/general/extension.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import * as path from 'path';
2828
import * as vscode from 'vscode';
2929
import * as myExplorer from '../../../../views/projects';
3030
import { CodeAction, commands, extensions, Selection, Uri, window, workspace, TreeItem } from 'vscode';
31-
import { assertWorkspace, awaitClient, dumpJava, findClusters, getFilePaths, openFile, prepareProject, replaceCode } from '../../testutils';
31+
import { addSleepIfWindowsPlatform, assertWorkspace, awaitClient, dumpJava, findClusters, getFilePaths, openFile, prepareProject, replaceCode } from '../../testutils';
3232
import { FORMATTED_POM_XML, SAMPLE_CODE_FORMAT_DOCUMENT, SAMPLE_CODE_SORT_IMPORTS, SAMPLE_CODE_UNUSED_IMPORTS } from '../../constants';
3333
import { extCommands } from '../../../../commands/commands';
3434

@@ -124,7 +124,7 @@ suite('Extension Test Suite', function () {
124124
test("Sort imports", async () => {
125125
const editor = await openFile(filePaths.sortImports);
126126
await replaceCode(editor, SAMPLE_CODE_SORT_IMPORTS);
127-
127+
await addSleepIfWindowsPlatform();
128128
const isSaved = await editor.document.save();
129129
assert.ok(isSaved, "document cannot be saved");
130130

@@ -139,7 +139,7 @@ suite('Extension Test Suite', function () {
139139
test("Remove unused imports", async () => {
140140
const editor = await openFile(filePaths.unusedImports);
141141
await replaceCode(editor, SAMPLE_CODE_UNUSED_IMPORTS);
142-
142+
await addSleepIfWindowsPlatform();
143143
const isSaved = await editor.document.save();
144144
assert.ok(isSaved, "document cannot be saved");
145145

vscode/src/test/integration/testutils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import * as assert from "assert";
2525
import * as fs from "fs";
26+
import * as os from "os";
2627
import { glob } from 'glob';
2728
import * as Mocha from 'mocha';
2829
import * as path from "path";
@@ -625,4 +626,11 @@ function isLocalizedObj(obj: any, localisableFields: any, id: string, category:
625626
}
626627
}
627628
return localized;
629+
}
630+
631+
export const addSleepIfWindowsPlatform = async (): Promise<void> => {
632+
if (os.type().includes("Windows")) {
633+
const timeoutEnv = parseInt(process.env['oracle_oracleJava_windows_sleep_timeout'] || "30000");
634+
await new Promise<void>(r => setTimeout(() => r(), timeoutEnv));
635+
}
628636
}

0 commit comments

Comments
 (0)