Skip to content

Commit 321cfd1

Browse files
authored
chore: Fix error in CI test process (#388)
1 parent d956042 commit 321cfd1

File tree

8 files changed

+34
-31
lines changed

8 files changed

+34
-31
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ matrix:
77
jdk: openjdk11
88
env:
99
- JDK_HOME=~/openjdk11 # force launching JLS using JDK11
10-
# Temporary disable osx since it will stuck after finishing test
11-
#- os: osx
12-
# osx_image: xcode10.1
13-
# jdk: oraclejdk11
10+
- os: osx
11+
osx_image: xcode10.1
12+
jdk: oraclejdk11
1413

1514
addons:
1615
apt:

extension.bundle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export { WorkspaceNode } from "./src/views/workspaceNode";
2020
export { contextManager } from "./src/contextManager";
2121
export { DependencyExplorer } from "./src/views/dependencyExplorer";
2222
export { Commands } from "./src/commands";
23+
export { LanguageServerMode } from "./src/extension";

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function isSwitchingServer(): boolean {
9898

9999
let serverMode: string | undefined;
100100

101-
const enum LanguageServerMode {
101+
export const enum LanguageServerMode {
102102
LightWeight = "LightWeight",
103103
Standard = "Standard",
104104
Hybrid = "Hybrid",

test/gradle-suite/projectView.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
// Licensed under the MIT license.
33

44
import * as assert from "assert";
5-
import { commands, extensions } from "vscode";
6-
import { Commands, ContainerNode, contextManager, DependencyExplorer,
5+
import { ContainerNode, contextManager, DependencyExplorer,
76
PackageRootNode, PrimaryTypeNode, ProjectNode } from "../../extension.bundle";
8-
import { fsPath, Uris } from "../shared";
7+
import { fsPath, setupTestEnv, Uris } from "../shared";
98

109
// tslint:disable: only-arrow-functions
1110
suite("Gradle Project View Tests", () => {
1211

13-
suiteSetup(async function() {
14-
await extensions.getExtension("vscjava.vscode-java-dependency")!.activate();
15-
// context would be initialized after this command
16-
await commands.executeCommand(Commands.JAVA_PROJECT_ACTIVATE);
17-
});
12+
suiteSetup(setupTestEnv);
1813

1914
test("Can node render correctly", async function() {
2015
const explorer = DependencyExplorer.getInstance(contextManager.context);

test/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ async function main(): Promise<void> {
6161
path.join(__dirname, "..", "..", "test", "gradle"),
6262
],
6363
});
64+
65+
process.exit(0);
66+
6467
} catch (err) {
6568
process.exit(1);
6669
}

test/maven-suite/projectView.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
// Licensed under the MIT license.
33

44
import * as assert from "assert";
5-
import { commands, extensions } from "vscode";
6-
import { Commands, ContainerNode, contextManager, DependencyExplorer,
5+
import { ContainerNode, contextManager, DependencyExplorer,
76
PackageNode, PackageRootNode, PrimaryTypeNode, ProjectNode } from "../../extension.bundle";
8-
import { fsPath, Uris } from "../shared";
7+
import { fsPath, setupTestEnv, Uris } from "../shared";
98

109
// tslint:disable: only-arrow-functions
1110
suite("Maven Project View Tests", () => {
1211

13-
suiteSetup(async function() {
14-
await extensions.getExtension("vscjava.vscode-java-dependency")!.activate();
15-
// context would be initialized after this command
16-
await commands.executeCommand(Commands.JAVA_PROJECT_ACTIVATE);
17-
});
12+
suiteSetup(setupTestEnv);
1813

1914
test("Can node render correctly", async function() {
2015
const explorer = DependencyExplorer.getInstance(contextManager.context);

test/shared.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Licensed under the MIT license.
33

44
import * as path from "path";
5-
import { Uri } from "vscode";
6-
import { DataNode } from "../extension.bundle";
5+
import { commands, Event, extensions, Uri } from "vscode";
6+
import { Commands, DataNode, LanguageServerMode } from "../extension.bundle";
77

88
export namespace Uris {
99
// Simple Project
@@ -37,3 +37,18 @@ export function truePath(...paths: string[]) {
3737
const basePath = path.join(__dirname, "..", "..", "test");
3838
return path.join(basePath, ...paths);
3939
}
40+
41+
export async function setupTestEnv() {
42+
await new Promise(async (resolve) => {
43+
const extensionApi: any = extensions.getExtension("redhat.java")!.exports;
44+
extensionApi.onDidServerModeChange(async (mode: string) => {
45+
if (mode === LanguageServerMode.Standard) {
46+
resolve();
47+
}
48+
});
49+
50+
await extensions.getExtension("vscjava.vscode-java-dependency")!.activate();
51+
// context would be initialized after this command
52+
await commands.executeCommand(Commands.JAVA_PROJECT_ACTIVATE);
53+
});
54+
}

test/simple-suite/projectView.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
// Licensed under the MIT license.
33

44
import * as assert from "assert";
5-
import { commands, extensions } from "vscode";
6-
import { Commands, ContainerNode, contextManager, DependencyExplorer,
5+
import { ContainerNode, contextManager, DependencyExplorer,
76
PackageRootNode, PrimaryTypeNode, ProjectNode } from "../../extension.bundle";
8-
import { fsPath, Uris } from "../shared";
7+
import { fsPath, setupTestEnv, Uris } from "../shared";
98

109
// tslint:disable: only-arrow-functions
1110
suite("Simple Project View Tests", () => {
1211

13-
suiteSetup(async function() {
14-
await extensions.getExtension("vscjava.vscode-java-dependency")!.activate();
15-
// context would be initialized after this command
16-
await commands.executeCommand(Commands.JAVA_PROJECT_ACTIVATE);
17-
});
12+
suiteSetup(setupTestEnv);
1813

1914
test("Can node render correctly", async function() {
2015
const explorer = DependencyExplorer.getInstance(contextManager.context);

0 commit comments

Comments
 (0)