nodejs / nodejs/node-api-cts

Harness primitive for testing expected crashes / uncaught exceptions

Aperta
#33 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C
Stelle
18
Fork
12
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Problem

Several upstream Node.js tests verify behavior that causes the process to exit abnormally — uncaught exceptions from finalizers, fatal errors, etc. These tests use a subprocess pattern:

  1. Spawn a child process that loads the addon and triggers the crash
  2. Assert on the child's exit code and stderr output

The CTS currently has no equivalent harness primitive for this pattern.

Affected tests

  • test_exception/testFinalizerException.js (js-native-api) — finalizer throws during GC, expects process exit with "Error during Finalize" on stderr
  • test_fatal (node-api) — calls napi_fatal_error, expects process abort with specific message

Proposed solution

Add a harness helper that runs a code snippet in a subprocess and asserts on the outcome:

// Possible API shape:
await expectCrash({
  code: () => {
    const addon = loadAddon('test_exception');
    addon.createExternal();
    // trigger GC...
  },
  stderr: /Error during Finalize/,
  exitCode: (code) => code !== 0,
});

Each implementor would provide the subprocess execution mechanism (e.g., Node.js would use child_process.spawnSync).

Considerations

  • The helper needs to be implementor-provided since subprocess APIs are runtime-specific
  • The test code to run in the subprocess may need access to loadAddon and other CTS globals
  • Some crashes are signal-based (SIGABRT from napi_fatal_error) vs exception-based — the helper should handle both

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo test_exception/testFinalizerException.js e test_fatal per confrontare le loro aspettative sui subprocess. Progetta l’harness fornito dall’implementatore attorno alla forma proposta di expectCrash, includendo la corrispondenza di stderr e la terminazione basata su un’eccezione o un segnale. Il lavoro è completato quando entrambi i test interessati possono usare l’helper e continuano a verificare gli esiti di crash previsti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
testing-qa
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.