-
Notifications
You must be signed in to change notification settings - Fork 83
Add basic Electron tests and pump its version for demos #1379
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
+182
−8
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
48bf45c
Add basic Electron tests and pump its version for demos
minggangw 8ba28c1
Address comments
minggangw 3296e7e
Fix sandbox issue
minggangw 94dc461
Fix headless env issue
minggangw ca76b7e
Add dependency support
minggangw cb20498
Fix libasound2 issue
minggangw c74b595
Fix dependency issue
minggangw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,6 @@ | |
| }, | ||
| "devDependencies": { | ||
| "@electron/rebuild": "^3.6.0", | ||
| "electron": "^31.0.0" | ||
| "electron": "^40.0.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,6 @@ | |
| }, | ||
| "devDependencies": { | ||
| "@electron/rebuild": "^3.7.2", | ||
| "electron": "^31.7.7" | ||
| "electron": "^40.0.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,6 @@ | |
| }, | ||
| "devDependencies": { | ||
| "@electron/rebuild": "^3.6.0", | ||
| "electron": "^31.0.0" | ||
| "electron": "^40.0.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,6 @@ | |
| }, | ||
| "devDependencies": { | ||
| "@electron/rebuild": "^3.7.2", | ||
| "electron": "^31.7.7" | ||
| "electron": "^40.0.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| 'use strict'; | ||
|
|
||
| const path = require('path'); | ||
| const { spawn } = require('child_process'); | ||
|
|
||
| let electron; | ||
| try { | ||
| electron = require('electron'); | ||
| } catch (e) { | ||
| console.error( | ||
| 'Electron module not found. Please install electron to run this test.' | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| let command = electron; | ||
| let args = [path.join(__dirname, 'test_usability.js'), '--no-sandbox']; | ||
|
|
||
| // Handle headless Linux environments (like CI) by using xvfb-run | ||
| if (process.platform === 'linux' && !process.env.DISPLAY) { | ||
| console.log('No DISPLAY detected. Attempting to use xvfb-run...'); | ||
| command = 'xvfb-run'; | ||
| // -a: --auto-servernum (use explicit server number to avoid conflicts) | ||
| args = ['-a', electron, ...args]; | ||
| } | ||
|
|
||
| console.log('Launching Electron to run test_usability.js...'); | ||
| const child = spawn(command, args, { | ||
| stdio: 'inherit', | ||
| env: { ...process.env, ELECTRON_ENABLE_LOGGING: true }, | ||
| }); | ||
|
|
||
| child.on('close', (code) => { | ||
| console.log(`Electron process exited with code ${code}`); | ||
| if (code === 0) { | ||
| console.log('Test Passed!'); | ||
| process.exit(0); | ||
| } else { | ||
| console.error('Test Failed!'); | ||
| process.exit(1); | ||
| } | ||
| }); | ||
|
|
||
| child.on('error', (err) => { | ||
| console.error('Failed to start electron:', err); | ||
| process.exit(1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| 'use strict'; | ||
|
|
||
| const rclnodejs = require('../../index.js'); | ||
| const { app } = require('electron'); | ||
|
|
||
| app.on('ready', () => { | ||
| console.log('Electron version:', process.versions.electron); | ||
| rclnodejs | ||
| .init() | ||
| .then(() => { | ||
| console.log('rclnodejs initialized successfully.'); | ||
| const node = rclnodejs.createNode('test_electron_node'); | ||
| const publisher = node.createPublisher( | ||
| 'std_msgs/msg/String', | ||
| 'electron_test_topic' | ||
| ); | ||
|
|
||
| const subscription = node.createSubscription( | ||
| 'std_msgs/msg/String', | ||
| 'electron_test_topic', | ||
| (msg) => { | ||
| if (msg.data === 'Hello from Electron') { | ||
| console.log( | ||
| 'Successfully received message in Electron environment.' | ||
| ); | ||
| rclnodejs.shutdown(); | ||
| app.quit(); | ||
| process.exit(0); | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| console.log('Publisher and Subscriber created.'); | ||
|
|
||
| // Publish repeatedly until received | ||
| const interval = setInterval(() => { | ||
| publisher.publish('Hello from Electron'); | ||
| console.log('Published message...'); | ||
| }, 100); | ||
|
|
||
| // Set a timeout to fail the test | ||
| setTimeout(() => { | ||
| console.error('Test Failed: Timeout waiting for message.'); | ||
| clearInterval(interval); | ||
| rclnodejs.shutdown(); | ||
| app.quit(); | ||
| process.exit(1); | ||
| }, 10000); | ||
|
|
||
| rclnodejs.spin(node); | ||
| }) | ||
| .catch((e) => { | ||
| console.error('Initialization failed:', e); | ||
| app.quit(); | ||
| process.exit(1); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.