Skip to content

Fix build script and tests for windows platform #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<copy file="vscode/package.json" todir="${build.dir}/bundles/package" />
<copy file="vscode/package-lock.json" todir="${build.dir}/bundles/package" />

<exec executable="mvn" failonerror="true" dir="${nb_all}/nbbuild/misc/prepare-bundles">
<exec executable="mvn${cmd.suffix}" failonerror="true" dir="${nb_all}/nbbuild/misc/prepare-bundles">
<arg value="package" />
<arg value="exec:java" />
<arg value="-Dexec.mainClass=org.netbeans.prepare.bundles.PrepareBundles" />
Expand Down
18 changes: 16 additions & 2 deletions patches/7271.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java b/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java
index 5349a20e09..952709d10b 100644
index 5349a20e09..f2b040204e 100644
--- a/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java
+++ b/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java
@@ -58,7 +58,8 @@ public class PrepareBundles {
Expand All @@ -12,7 +12,21 @@ index 5349a20e09..952709d10b 100644
);
private static final String nl = "\n";

@@ -107,18 +108,18 @@ public class PrepareBundles {
@@ -69,7 +70,12 @@ public class PrepareBundles {

Path targetDir = Paths.get(args[0]);
Path packagesDir = targetDir.resolve("package");
- new ProcessBuilder("npm", "install").directory(packagesDir.toFile()).inheritIO().start().waitFor();
+ String os = System.getProperty("os.name").toLowerCase();
+ if (os.contains("windows")) {
+ new ProcessBuilder("npm.cmd", "install").directory(packagesDir.toFile()).inheritIO().start().waitFor();
+ } else{
+ new ProcessBuilder("npm", "install").directory(packagesDir.toFile()).inheritIO().start().waitFor();
+ }
Path bundlesDir = targetDir.resolve("bundles");
Files.createDirectories(bundlesDir);
try (DirectoryStream<Path> ds = Files.newDirectoryStream(bundlesDir)) {
@@ -107,18 +113,18 @@ public class PrepareBundles {
if ("@types".equals(module.getFileName().toString())) continue;
if ("@esbuild".equals(module.getFileName().toString())) continue;
if ("@microsoft".equals(module.getFileName().toString())) continue;
Expand Down
4 changes: 2 additions & 2 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,9 @@
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./; node ./esbuild.js",
"compile": "tsc -p ./ && node ./esbuild.js",
"watch": "tsc -watch -p ./ | node ./esbuild.js --watch",
"test": "node ./out/test/runTest.js",
"test": "npm run compile && node ./out/test/runTest.js",
"nbcode": "node ./out/nbcode.js",
"nbjavac": "node ./out/nbcode.js -J-Dnetbeans.close=true --modules --install .*nbjavac.*",
"apisupport": "node ./out/nbcode.js -J-Dnetbeans.close=true --modules --install '(org.netbeans.libs.xerces|org.netbeans.modules.editor.structure|org.netbeans.modules.xml|org.netbeans.modules.xml.axi|org.netbeans.modules.xml.retriever|org.netbeans.modules.xml.schema.model|org.netbeans.modules.xml.tax|org.netbeans.modules.xml.text|org.netbeans.modules.ant.browsetask|.*apisupport.*|org.netbeans.modules.debugger.jpda.ant)' && node ./out/nbcode.js -J-Dnetbeans.close=true --modules --enable .*apisupport.ant",
Expand Down
25 changes: 15 additions & 10 deletions vscode/src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,27 @@ async function main() {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
const outRootPath = path.join(extensionDevelopmentPath, 'out');

const vscodeExecutablePath: string = await downloadAndUnzipVSCode('stable');

const outRoot = path.join(extensionDevelopmentPath, "out");
const extDir = path.join(outRoot, "test", "vscode", "exts");
const userDir = path.join(outRoot, "test", "vscode", "user");

const testSuites = fs.readdirSync(path.resolve(__dirname, './suite'));
const vscodeTestDir = path.join(__dirname, "vscode");
const extDir = path.join(vscodeTestDir, "exts");
const userDir = path.join(vscodeTestDir, "user");
const suitesDir = path.join(__dirname, 'suite');
const testSuites = fs.readdirSync(suitesDir);

for (const suiteName of testSuites) {
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, `./suite/${suiteName}/index`);
const workspaceDir = path.join(extensionDevelopmentPath, 'out', 'test', 'suite', suiteName, 'ws');
if (!fs.statSync(workspaceDir).isDirectory()) {
throw `Expecting ${workspaceDir} to be a directory!`;
const suiteDir = path.join(suitesDir, suiteName);
const extensionTestsPath = path.join(suiteDir, 'index');
const workspaceDir = path.join(suiteDir, 'ws');

if (fs.existsSync(workspaceDir)) {
fs.rmdirSync(workspaceDir, { recursive: true });
}
fs.mkdirSync(workspaceDir, { recursive: true });

// Download VS Code, unzip it and run the integration test
await runTests({
Expand All @@ -53,7 +57,7 @@ async function main() {
extensionTestsPath,
extensionTestsEnv: {
'ENABLE_CONSOLE_LOG': 'true',
"netbeans.extra.options": `-J-Dproject.limitScanRoot=${outRoot} -J-Dnetbeans.logger.console=true`
"netbeans.extra.options": `-J-Dproject.limitScanRoot=${outRootPath} -J-Dnetbeans.logger.console=true`
},
launchArgs: [
'--disable-extensions',
Expand All @@ -66,6 +70,7 @@ async function main() {
}
} catch (err) {
console.error('Failed to run tests');
console.error((err as Error).message);
process.exit(1);
}
}
Expand Down
10 changes: 0 additions & 10 deletions vscode/src/test/suite/general/explorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,12 @@
*/

import * as assert from 'assert';
import * as fs from 'fs';
import * as Mocha from 'mocha';

// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
import * as myExtension from '../../../extension';
import * as myExplorer from '../../../explorer';
import { assertWorkspace } from '../../testutils';

Mocha.before(async () => {
vscode.window.showInformationMessage('Cleaning up workspace.');
let folder: string = assertWorkspace();
await fs.promises.rmdir(folder, { recursive: true });
await fs.promises.mkdir(folder, { recursive: true });
});

suite('Explorer Test Suite', () => {
vscode.window.showInformationMessage('Start explorer tests.');
Expand Down
16 changes: 8 additions & 8 deletions vscode/src/test/suite/general/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ suite('Extension Test Suite', function () {
let found: string[] = [];
function assertCluster(name: string) {
for (let c of clusters) {
if (c.endsWith('/' + name)) {
if (c.endsWith('/' + name) || c.endsWith('\\' + name)) {
found.push(c);
return;
}
Expand Down Expand Up @@ -232,31 +232,31 @@ suite('Extension Test Suite', function () {
console.log(`Test: get project java source roots finished with ${res}`);
assert.ok(res, "No java source root returned");
assert.strictEqual(res.length, 2, `Invalid number of java roots returned`);
assert.strictEqual(res[0], path.join('file:', folder, 'src', 'main', 'java') + path.sep, `Invalid java main source root returned`);
assert.strictEqual(res[1], path.join('file:', folder, 'src', 'test', 'java') + path.sep, `Invalid java test source root returned`);
assert.strictEqual(path.join(res[0]).toLowerCase(), (path.join('file:', folder, 'src', 'main', 'java') + path.sep).toLowerCase(), `Invalid java main source root returned`);
assert.strictEqual(path.join(res[1]).toLowerCase(), (path.join('file:', folder, 'src', 'test', 'java') + path.sep).toLowerCase(), `Invalid java test source root returned`);

console.log("Test: get project resource roots");
res = await commands.executeCommand("jdk.java.get.project.source.roots", Uri.file(folder).toString(), 'resources');
console.log(`Test: get project resource roots finished with ${res}`);
assert.ok(res, "No resource root returned");
assert.strictEqual(res.length, 1, `Invalid number of resource roots returned`);
assert.strictEqual(res[0], path.join('file:', folder, 'src', 'main', 'resources') + path.sep, `Invalid resource root returned`);
assert.strictEqual(path.join(res[0]).toLowerCase(), (path.join('file:', folder, 'src', 'main', 'resources') + path.sep).toLowerCase(), `Invalid resource root returned`);

console.log("Test: get project compile classpath");
res = await commands.executeCommand("jdk.java.get.project.classpath", Uri.file(folder).toString());
console.log(`Test: get project compile classpath finished with ${res}`);
assert.ok(res, "No compile classpath returned");
assert.strictEqual(res.length, 9, `Invalid number of compile classpath roots returned`);
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'target', 'classes') + path.sep, `Invalid compile classpath root returned`));
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'target', 'classes') + path.sep).toLowerCase(), `Invalid compile classpath root returned`));

console.log("Test: get project source classpath");
res = await commands.executeCommand("jdk.java.get.project.classpath", Uri.file(folder).toString(), 'SOURCE');
console.log(`Test: get project source classpath finished with ${res}`);
assert.ok(res, "No source classpath returned");
assert.strictEqual(res.length, 3, `Invalid number of source classpath roots returned`);
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'src', 'main', 'java') + path.sep, `Invalid source classpath root returned`));
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'src', 'main', 'resources') + path.sep, `Invalid source classpath root returned`));
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'src', 'test', 'java') + path.sep, `Invalid source classpath root returned`));
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'src', 'main', 'java') + path.sep).toLowerCase(), `Invalid source classpath root returned`));
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'src', 'main', 'resources') + path.sep).toLowerCase(), `Invalid source classpath root returned`));
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'src', 'test', 'java') + path.sep).toLowerCase(), `Invalid source classpath root returned`));

console.log("Test: get project boot classpath");
res = await commands.executeCommand("jdk.java.get.project.classpath", Uri.file(folder).toString(), 'BOOT');
Expand Down
15 changes: 6 additions & 9 deletions vscode/src/test/suite/gradle/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@

import * as assert from "assert";
import * as fs from "fs";
import * as Mocha from 'mocha';
import * as path from "path";

import { commands, window } from "vscode";
import { assertWorkspace, dumpJava, gradleInitJavaApplication } from "../../testutils";

Mocha.before(async () => {
window.showInformationMessage('Cleaning up workspace.');
let folder: string = assertWorkspace();
await fs.promises.rmdir(folder, { recursive: true });
await fs.promises.mkdir(folder, { recursive: true });
});

suite("Extension gradle tests", function () {
window.showInformationMessage("Starting Gradle tests");
Expand All @@ -49,8 +42,12 @@ suite("Extension gradle tests", function () {
const mainClass = path.join(
folder,
"build",
"classes/java",
"main/org/yourCompany/yourProject",
"classes",
"java",
"main",
"org",
"yourCompany",
"yourProject",
"App.class"
);
assert.ok(
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export function runTestSuite(folder: string): Promise<void> {
const mocha = new Mocha({
ui: 'tdd',
color: true,
timeout: 60000
timeout: 10*1000*60
});

const testsRoot = path.resolve(folder);
Expand Down