Skip to content

fix signal handling - #48

Merged
avtolstoy merged 2 commits into
masterfrom
fix/signal-handling
Aug 31, 2026
Merged

avtolstoy merged 2 commits into
masterfrom
fix/signal-handling

Conversation

@avtolstoy

@avtolstoy avtolstoy commented Aug 31, 2026

Copy link
Copy Markdown
Member

Problem

The runner ignores Ctrl-C, the terminal echoes ^C but tests keep running.

The gist: in Node, any SIGINT listener removes the default terminate behavior, and one that never calls process.exit() swallows the signal entirely. The runner loads all *.spec.js before applying filters, so a cleanup-only signal handler registered at module load by a shared helper (user/tests/integration/test/tethering.js) leaks into every run.

Solution

Adds InterruptHandler (lib/interrupt.js) - installs SIGINT/SIGTERM listeners before test files are loaded, runs best-effort cleanup (runner.shutdown()) on signal, then exits with the appropriate code. Second signal during cleanup exits immediately. Other listeners still run, so cleanup registered by test helpers is not lost.

@avtolstoy
avtolstoy requested a review from scott-brust August 31, 2026 17:48
@scott-brust

Copy link
Copy Markdown
Member

No warning when building

Single ^C exits the test suite

➜  device-os git:(fix/gen3-usb-cdc-migrate-usbserial-tests) ✗ device-os-test --verbose --device-os-dir=. build wiring/no_fixture msom
Test directory: /Users/sbrust/develop/device-os/user/tests/integration
Device OS directory: /Users/sbrust/develop/device-os
Firmware binaries directory: /Users/sbrust/develop/device-os/build/integration
Target directory: /Users/sbrust/develop/device-os/build/integration
Building application: wiring/no_fixture
Platforms: msom
➜  device-os git:(fix/gen3-usb-cdc-migrate-usbserial-tests) ✗ device-os-test --verbose --device-os-dir=. run wiring/no_fixture msom
Test directory: /Users/sbrust/develop/device-os/user/tests/integration
Device OS directory: /Users/sbrust/develop/device-os
Firmware binaries directory: /Users/sbrust/develop/device-os/build/integration
Initializing API client
URL: https://api.particle.io
Authenticating with access token
Signed in as device-os-ci@particle.io
Subscribing to device events
Initializing device manager
Enumerating USB devices
Retrieving devices from the cloud
Device pool:
0a10aced202194944a04b000 (scott-us-msom-bg95m5-dvt1-03)
No fixtures configured
Generating test matrix
Running tests


  No fixture
    msom
      Target device: 0a10aced202194944a04b000 (scott-us-msom-bg95m5-dvt1-03)
      Flashing application: no_fixture.bin
      Getting device tests
      systemThread=disabled
          Initializing device test suite
          Running device test: APPLICATION_WATCHDOG_01_fires_timeout
          Device test passed
        ✓ APPLICATION_WATCHDOG_01_fires_timeout (4.9s)
          Running device test: APPLICATION_WATCHDOG_02_doesnt_fire_when_app_checks_in
^C
Received SIGINT, terminating

@avtolstoy
avtolstoy merged commit 8c84cc4 into master Aug 31, 2026
2 checks passed
@avtolstoy
avtolstoy deleted the fix/signal-handling branch August 31, 2026 18:42
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.

2 participants