Skip to content

Conversation

@minggangw
Copy link
Member

@minggangw minggangw commented Jan 8, 2026

Summary

Enhanced unit test coverage for core library modules and simplified CI configuration.

Details

  • Test Coverage Improvements:

    • Added comprehensive unit tests for utils.js, time_source.js, native_loader.js, timer.js, message_validation.js, message_serialization.js, client.js, event_handler.js, and logging.js.
    • Achieved >80% code coverage for these modules.
    • Fixed compatibility issues for ROS 2 Humble (added conditional checks and mocks stubOptional for newer API features like setOnResetCallback).
  • CI Configuration:

    • Updated .github/workflows/linux-x64-build-and-test.yml to remove the redundant finish job and parallel Coveralls upload, streamlining the process for single-job coverage reporting.

Fix: #1362

Copilot AI review requested due to automatic review settings January 8, 2026 10:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive test coverage across multiple areas of the rclnodejs library. The changes introduce 15 new or modified test files that significantly expand validation, error handling, and edge case testing.

Key Changes:

  • Added extensive validation error tests for messages and parameters
  • Introduced comprehensive utility function tests
  • Added error path coverage for node operations, logging, and client-service interactions
  • Extended existing test files with additional test cases for time sources, guard conditions, and async clients

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
test/test-validation-errors.js New comprehensive tests for message validation errors including type mismatches, range validation, and array validation
test/test-utils.js New tests for utility functions including file operations, version comparison, and node name normalization
test/test-time-source.js Extended existing tests with new cases for ROS time activation and node attachment/detachment
test/test-rmw.js New tests for RMW (ROS Middleware) utility functions and environment variable handling
test/test-parameters.js Extended parameter tests with comprehensive descriptor tests, ranges, and special value handling
test/test-parameter-validation-errors.js New extensive tests for parameter validation including type checking, range validation, and read-only enforcement
test/test-node-error-paths.js New comprehensive error path tests for node creation, publishers, subscriptions, services, and lifecycle management
test/test-message-validation.js Extended message validation tests with additional message type handling
test/test-message-serialization-coverage.js New comprehensive tests for message serialization covering TypedArrays, JSON conversion, and edge cases
test/test-logging-coverage.js New extensive logging tests covering severity levels, conditional logging, and logger hierarchy
test/test-guard-condition.js Extended tests with context handling and callback getter tests
test/test-clock-event.js Modified copyright header and updated comments
test/test-client-service-coverage.js New comprehensive client-service tests covering creation, communication, error handling, and QoS variations
test/test-async-client.js Extended with AbortSignal polyfill tests and validation method tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

it('should send request and receive response', async function () {
const serviceName = `add_service_${Date.now()}`;

const service = serviceNode.createService(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable service.

Suggested change
const service = serviceNode.createService(
serviceNode.createService(

Copilot uses AI. Check for mistakes.
it('should handle multiple requests', async function () {
const serviceName = `multi_service_${Date.now()}`;

const service = serviceNode.createService(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable service.

Copilot uses AI. Check for mistakes.
it('should handle zero values', async function () {
const serviceName = `zero_service_${Date.now()}`;

const service = serviceNode.createService(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable service.

Copilot uses AI. Check for mistakes.
it('should handle negative values', async function () {
const serviceName = `negative_service_${Date.now()}`;

const service = serviceNode.createService(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable service.

Copilot uses AI. Check for mistakes.
it('should handle large values', async function () {
const serviceName = `large_service_${Date.now()}`;

const service = serviceNode.createService(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable service.

Copilot uses AI. Check for mistakes.

it('should clean up publishers on node destroy', function () {
const node = rclnodejs.createNode('cleanup_pub_test');
const pub = node.createPublisher('std_msgs/msg/String', 'test_topic');
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable pub.

Copilot uses AI. Check for mistakes.

it('should clean up subscriptions on node destroy', function () {
const node = rclnodejs.createNode('cleanup_sub_test');
const sub = node.createSubscription(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable sub.

Copilot uses AI. Check for mistakes.

it('should clean up timers on node destroy', function () {
const node = rclnodejs.createNode('cleanup_timer_test');
const timer = node.createTimer(100, () => {});
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable timer.

Suggested change
const timer = node.createTimer(100, () => {});
node.createTimer(100, () => {});

Copilot uses AI. Check for mistakes.

it('should clean up clients on node destroy', function () {
const node = rclnodejs.createNode('cleanup_client_test');
const client = node.createClient(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable client.

Suggested change
const client = node.createClient(
node.createClient(

Copilot uses AI. Check for mistakes.

it('should clean up services on node destroy', function () {
const node = rclnodejs.createNode('cleanup_service_test');
const service = node.createService(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable service.

Suggested change
const service = node.createService(
node.createService(

Copilot uses AI. Check for mistakes.
@coveralls
Copy link

coveralls commented Jan 9, 2026

Coverage Status

coverage: 85.565% (+4.9%) from 80.626%
when pulling 53c4db2 on minggangw:fix-1362
into b7627b7 on RobotWebTools:develop.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

await utils.ensureDir(dir);
});

it('should valid ensureDirSync works correctly', function () {
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test description has grammatically incorrect wording. It should be "should verify that ensureDirSync works correctly" or "should validate that ensureDirSync works correctly" instead of "should valid ensureDirSync works correctly".

Copilot uses AI. Check for mistakes.
utils.ensureDirSync(dir);
});

it('should valid emptyDir works correctly', async function () {
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test description has grammatically incorrect wording. It should be "should verify that emptyDir works correctly" or "should validate that emptyDir works correctly" instead of "should valid emptyDir works correctly".

Copilot uses AI. Check for mistakes.
@minggangw minggangw changed the title Add more tests Add tests to improve coverage Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve test coverage

2 participants