You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "petrovic-d (via GitHub)" <gi...@apache.org> on 2025/03/04 08:37:42 UTC
[PR] Micronaut launcher tests [netbeans]
petrovic-d opened a new pull request, #8293:
URL: https://github.com/apache/netbeans/pull/8293
Micronaut launcher tests that are testing commands exposed through code lenses - `nbls.run.single` (run and run in dev mode) and `nbls.debug.single`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Micronaut launcher tests [netbeans]
Posted by "sdedic (via GitHub)" <gi...@apache.org>.
sdedic commented on code in PR #8293:
URL: https://github.com/apache/netbeans/pull/8293#discussion_r2010020026
##########
java/java.lsp.server/vscode/src/test/launcher/launch.test.ts:
##########
@@ -0,0 +1,106 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from 'fs';
+import * as Mocha from 'mocha';
+import * as path from 'path';
+
+import * as vscode from 'vscode';
+import * as myExtension from '../../extension';
+import { assertWorkspace, waitProjectRecognized } from '../suite/testutils';
+import { copyDirSync, projectFileUri } from './fileUtil';
+
+Mocha.before(async () => {
+ vscode.window.showInformationMessage('Cleaning up workspace.');
+ let workspaceFolder: string = assertWorkspace();
+ fs.rmdirSync(workspaceFolder, { recursive: true });
+ fs.mkdirSync(workspaceFolder, { recursive: true });
+
+ const sourcePath = path.resolve(__dirname, '..' , '..', '..', 'test-projects', 'test-app');
+ copyDirSync(sourcePath, workspaceFolder);
+});
+
+const MAVEN_COMMAND_REGEX = /\/netbeans\/java\/java\.lsp\.server\/vscode\/nbcode\/java\/maven\/bin\/mvn/;
+const MAVEN_PLUGIN_RUN_REGEX = /io\.micronaut\.maven:micronaut-maven-plugin:run/;
+
+function isMavenCommand(input: string) {
+ return MAVEN_COMMAND_REGEX.test(input);
+}
+
+function createDebugConsoleEventCallback(verifyConditionCallback: CallableFunction, errorMessageCallback: CallableFunction, done: Mocha.Done): (value: string) => void {
+ return (value: string) => {
+ if (isMavenCommand(value)) {
+ vscode.commands.executeCommand("workbench.action.debug.stop");
+ myExtension.debugConsoleListeners.pop();
+ if (verifyConditionCallback(value)) {
+ done();
+ } else {
+ done(new Error(errorMessageCallback(value)))
+ }
+ }
+ }
+}
+
+suite('Micronaut Launcher Test Suite', () => {
+ vscode.window.showInformationMessage('Starting Micronaut launcher tests.');
+ myExtension.enableConsoleLog();
+
+ test('Micronaut run', (done) => {
+ let folder: string = assertWorkspace();
+ const verifyConditionCallback = (value: string) => new RegExp(/.*/.source + MAVEN_COMMAND_REGEX.source + /.*/.source + MAVEN_PLUGIN_RUN_REGEX.source).test(value);
+ const errorMessageCallback = (value: string) => `Output: ${value} doesn't contain exec-maven-plugin:exec command`;
+
+ myExtension.debugConsoleListeners.push({
Review Comment:
> Not sure what to you mean by pass the listener instance to the callback
Sorry; in the [ad6f973](https://github.com/apache/netbeans/commit/ad6f9738d9ebb112263f29766b3a774012b63947#diff-c7cb0640a86872590fe813e5fb1656a12d09c5b0219a207736627d8c63c3851bR51) version, the `createDebugConsoleEventCallback` pop-ed the last listener whatever it was. It would be more reliable if the listener actually registered by the test was pop-ed.
`clearDebugConsoleListeners()` solves it other way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Micronaut launcher tests [netbeans]
Posted by "ebarboni (via GitHub)" <gi...@apache.org>.
ebarboni commented on PR #8293:
URL: https://github.com/apache/netbeans/pull/8293#issuecomment-2809261724
fixing milestone as not yet branched
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Micronaut launcher tests [netbeans]
Posted by "MartinBalin (via GitHub)" <gi...@apache.org>.
MartinBalin merged PR #8293:
URL: https://github.com/apache/netbeans/pull/8293
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Micronaut launcher tests [netbeans]
Posted by "sdedic (via GitHub)" <gi...@apache.org>.
sdedic commented on code in PR #8293:
URL: https://github.com/apache/netbeans/pull/8293#discussion_r2009675723
##########
java/java.lsp.server/vscode/src/extension.ts:
##########
@@ -75,6 +75,7 @@ export let client: Promise<NbLanguageClient>;
export let clientRuntimeJDK : string | null = null;
export const MINIMAL_JDK_VERSION = 17;
export const TEST_PROGRESS_EVENT: string = "testProgress";
+export let debugConsoleListeners: any[] = [];
Review Comment:
Please type the callback as a `function(output : string) : void` or something != any. Right now the code requires the `callback` member to be present.
##########
java/java.lsp.server/vscode/src/test/launcher/launch.test.ts:
##########
@@ -0,0 +1,106 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from 'fs';
+import * as Mocha from 'mocha';
+import * as path from 'path';
+
+import * as vscode from 'vscode';
+import * as myExtension from '../../extension';
+import { assertWorkspace, waitProjectRecognized } from '../suite/testutils';
+import { copyDirSync, projectFileUri } from './fileUtil';
+
+Mocha.before(async () => {
+ vscode.window.showInformationMessage('Cleaning up workspace.');
+ let workspaceFolder: string = assertWorkspace();
+ fs.rmdirSync(workspaceFolder, { recursive: true });
+ fs.mkdirSync(workspaceFolder, { recursive: true });
+
+ const sourcePath = path.resolve(__dirname, '..' , '..', '..', 'test-projects', 'test-app');
+ copyDirSync(sourcePath, workspaceFolder);
+});
+
+const MAVEN_COMMAND_REGEX = /\/netbeans\/java\/java\.lsp\.server\/vscode\/nbcode\/java\/maven\/bin\/mvn/;
+const MAVEN_PLUGIN_RUN_REGEX = /io\.micronaut\.maven:micronaut-maven-plugin:run/;
+
+function isMavenCommand(input: string) {
+ return MAVEN_COMMAND_REGEX.test(input);
+}
+
+function createDebugConsoleEventCallback(verifyConditionCallback: CallableFunction, errorMessageCallback: CallableFunction, done: Mocha.Done): (value: string) => void {
+ return (value: string) => {
+ if (isMavenCommand(value)) {
+ vscode.commands.executeCommand("workbench.action.debug.stop");
+ myExtension.debugConsoleListeners.pop();
+ if (verifyConditionCallback(value)) {
+ done();
+ } else {
+ done(new Error(errorMessageCallback(value)))
+ }
+ }
+ }
+}
+
+suite('Micronaut Launcher Test Suite', () => {
+ vscode.window.showInformationMessage('Starting Micronaut launcher tests.');
+ myExtension.enableConsoleLog();
+
+ test('Micronaut run', (done) => {
+ let folder: string = assertWorkspace();
+ const verifyConditionCallback = (value: string) => new RegExp(/.*/.source + MAVEN_COMMAND_REGEX.source + /.*/.source + MAVEN_PLUGIN_RUN_REGEX.source).test(value);
+ const errorMessageCallback = (value: string) => `Output: ${value} doesn't contain exec-maven-plugin:exec command`;
+
+ myExtension.debugConsoleListeners.push({
Review Comment:
Please pass the listener instance to the callback; right now the topmost listener is cleared whatever it is. Also please clean the listener in a case that the launch process gets stuck and the listener never receives `isMavenCommand()`.
Maybe listeners [] can be cleared in an `afterEach()` Mocha handler.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Micronaut launcher tests [netbeans]
Posted by "petrovic-d (via GitHub)" <gi...@apache.org>.
petrovic-d commented on code in PR #8293:
URL: https://github.com/apache/netbeans/pull/8293#discussion_r2009784811
##########
java/java.lsp.server/vscode/src/test/launcher/launch.test.ts:
##########
@@ -0,0 +1,106 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from 'fs';
+import * as Mocha from 'mocha';
+import * as path from 'path';
+
+import * as vscode from 'vscode';
+import * as myExtension from '../../extension';
+import { assertWorkspace, waitProjectRecognized } from '../suite/testutils';
+import { copyDirSync, projectFileUri } from './fileUtil';
+
+Mocha.before(async () => {
+ vscode.window.showInformationMessage('Cleaning up workspace.');
+ let workspaceFolder: string = assertWorkspace();
+ fs.rmdirSync(workspaceFolder, { recursive: true });
+ fs.mkdirSync(workspaceFolder, { recursive: true });
+
+ const sourcePath = path.resolve(__dirname, '..' , '..', '..', 'test-projects', 'test-app');
+ copyDirSync(sourcePath, workspaceFolder);
+});
+
+const MAVEN_COMMAND_REGEX = /\/netbeans\/java\/java\.lsp\.server\/vscode\/nbcode\/java\/maven\/bin\/mvn/;
+const MAVEN_PLUGIN_RUN_REGEX = /io\.micronaut\.maven:micronaut-maven-plugin:run/;
+
+function isMavenCommand(input: string) {
+ return MAVEN_COMMAND_REGEX.test(input);
+}
+
+function createDebugConsoleEventCallback(verifyConditionCallback: CallableFunction, errorMessageCallback: CallableFunction, done: Mocha.Done): (value: string) => void {
+ return (value: string) => {
+ if (isMavenCommand(value)) {
+ vscode.commands.executeCommand("workbench.action.debug.stop");
+ myExtension.debugConsoleListeners.pop();
+ if (verifyConditionCallback(value)) {
+ done();
+ } else {
+ done(new Error(errorMessageCallback(value)))
+ }
+ }
+ }
+}
+
+suite('Micronaut Launcher Test Suite', () => {
+ vscode.window.showInformationMessage('Starting Micronaut launcher tests.');
+ myExtension.enableConsoleLog();
+
+ test('Micronaut run', (done) => {
+ let folder: string = assertWorkspace();
+ const verifyConditionCallback = (value: string) => new RegExp(/.*/.source + MAVEN_COMMAND_REGEX.source + /.*/.source + MAVEN_PLUGIN_RUN_REGEX.source).test(value);
+ const errorMessageCallback = (value: string) => `Output: ${value} doesn't contain exec-maven-plugin:exec command`;
+
+ myExtension.debugConsoleListeners.push({
Review Comment:
Not sure what to you mean by `pass the listener instance to the callback`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists