diff --git a/vscode/src/test/integration/suite/general/extension.test.ts b/vscode/src/test/integration/suite/general/extension.test.ts index 8c0bc2e4..499fc495 100644 --- a/vscode/src/test/integration/suite/general/extension.test.ts +++ b/vscode/src/test/integration/suite/general/extension.test.ts @@ -28,7 +28,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; import * as myExplorer from '../../../../views/projects'; import { CodeAction, commands, extensions, Selection, Uri, window, workspace, TreeItem } from 'vscode'; -import { assertWorkspace, awaitClient, dumpJava, findClusters, getFilePaths, openFile, prepareProject, replaceCode } from '../../testutils'; +import { addSleepIfWindowsPlatform, assertWorkspace, awaitClient, dumpJava, findClusters, getFilePaths, openFile, prepareProject, replaceCode } from '../../testutils'; import { FORMATTED_POM_XML, SAMPLE_CODE_FORMAT_DOCUMENT, SAMPLE_CODE_SORT_IMPORTS, SAMPLE_CODE_UNUSED_IMPORTS } from '../../constants'; import { extCommands } from '../../../../commands/commands'; @@ -124,7 +124,7 @@ suite('Extension Test Suite', function () { test("Sort imports", async () => { const editor = await openFile(filePaths.sortImports); await replaceCode(editor, SAMPLE_CODE_SORT_IMPORTS); - + await addSleepIfWindowsPlatform(); const isSaved = await editor.document.save(); assert.ok(isSaved, "document cannot be saved"); @@ -139,7 +139,7 @@ suite('Extension Test Suite', function () { test("Remove unused imports", async () => { const editor = await openFile(filePaths.unusedImports); await replaceCode(editor, SAMPLE_CODE_UNUSED_IMPORTS); - + await addSleepIfWindowsPlatform(); const isSaved = await editor.document.save(); assert.ok(isSaved, "document cannot be saved"); diff --git a/vscode/src/test/integration/testutils.ts b/vscode/src/test/integration/testutils.ts index 3bcf11e2..2dd5f360 100644 --- a/vscode/src/test/integration/testutils.ts +++ b/vscode/src/test/integration/testutils.ts @@ -23,6 +23,7 @@ import * as assert from "assert"; import * as fs from "fs"; +import * as os from "os"; import { glob } from 'glob'; import * as Mocha from 'mocha'; import * as path from "path"; @@ -625,4 +626,11 @@ function isLocalizedObj(obj: any, localisableFields: any, id: string, category: } } return localized; +} + +export const addSleepIfWindowsPlatform = async (): Promise => { + if (os.type().includes("Windows")) { + const timeoutEnv = parseInt(process.env['oracle_oracleJava_windows_sleep_timeout'] || "30000"); + await new Promise(r => setTimeout(() => r(), timeoutEnv)); + } } \ No newline at end of file