Skip to content

Commit fdb51e1

Browse files
committed
Fixed gradle integration tests initialization
Corrected the init of the test folder structure for gradle integration tests to correspond to that expected when created using `gradle init`.
1 parent 00659e3 commit fdb51e1

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ suite("Extension gradle tests", function () {
4141
assert.ok(compile, " Compile workspace command not working");
4242
const mainClass = path.join(
4343
folder,
44+
"yourProject",
4445
"build",
4546
"classes",
4647
"java",
@@ -55,21 +56,28 @@ suite("Extension gradle tests", function () {
5556
"Class created by compilation: " + mainClass
5657
);
5758
} catch (error) {
58-
dumpJava();
59+
await dumpJava();
60+
console.log(`Error: ${error}`);
5961
throw error;
6062
}
6163
});
6264

6365
// Check if clean workspace command is excuted succesfully
6466
test("Clean workspace - Gradle", async () => {
65-
let folder: string = assertWorkspace();
66-
const clean = await commands.executeCommand("jdk.workspace.clean");
67-
assert.ok(clean, " Clean workspace command not working");
67+
try {
68+
let folder: string = assertWorkspace();
69+
const clean = await commands.executeCommand("jdk.workspace.clean");
70+
assert.ok(clean, " Clean workspace command not working");
6871

69-
const mainClass = path.join(folder, "build");
70-
assert.ok(
71-
!fs.existsSync(mainClass),
72-
"Class created by compilation: " + mainClass
73-
);
72+
const buildFolder = path.join(folder, "yourProject", "build");
73+
assert.ok(
74+
!fs.existsSync(buildFolder),
75+
"Build removed by clean: " + buildFolder
76+
);
77+
} catch (error) {
78+
await dumpJava();
79+
console.log(`Error: ${error}`);
80+
throw error;
81+
}
7482
});
7583
});

vscode/src/test/integration/testutils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ export const runShellCommand = async (command: string, folderPath: string) => {
253253
export async function gradleInitJavaApplication(folder: string) {
254254
const basePackage = "org.yourCompany.yourProject";
255255

256-
const projectPath = path.join(folder);
256+
const rootProjectPath = path.join(folder);
257+
const projectPath = path.join(rootProjectPath, "yourProject");
257258
const srcMainPath = path.join(
258259
projectPath,
259260
"src",
@@ -272,6 +273,7 @@ export async function gradleInitJavaApplication(folder: string) {
272273

273274
try {
274275
// Create directories
276+
await fs.promises.mkdir(rootProjectPath, { recursive: true });
275277
await fs.promises.mkdir(projectPath, { recursive: true });
276278
await fs.promises.mkdir(srcMainPath, { recursive: true });
277279
await fs.promises.mkdir(resourcesPath, { recursive: true });
@@ -283,7 +285,7 @@ export async function gradleInitJavaApplication(folder: string) {
283285
SAMPLE_BUILD_GRADLE
284286
);
285287
await fs.promises.writeFile(
286-
path.join(projectPath, "settings.gradle"),
288+
path.join(rootProjectPath, "settings.gradle"),
287289
SAMPLE_SETTINGS_GRADLE
288290
);
289291
// Create Java main file
@@ -347,7 +349,7 @@ export const awaitClient = async () : Promise<NbLanguageClient> => {
347349
}
348350

349351
export function findClusters(myPath : string): string[] {
350-
let clusters = [];
352+
let clusters:string[] = [];
351353
for (let e of vscode.extensions.all) {
352354
if (e.extensionPath === myPath) {
353355
continue;

0 commit comments

Comments
 (0)