nodejs / nodejs/node-api-cts

Harness primitive for testing expected crashes / uncaught exceptions

Đang mở
#33 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C
Star
18
Fork
12
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách đọc test_exception/testFinalizerException.js và test_fatal để so sánh các kỳ vọng của chúng đối với subprocess. Thiết kế harness do implementor cung cấp xoay quanh dạng expectCrash được đề xuất, bao gồm việc so khớp stderr và việc kết thúc dựa trên exception hoặc signal. Công việc được xem là hoàn tất khi cả hai test bị ảnh hưởng đều có thể sử dụng helper mà vẫn xác minh các kết quả crash mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
testing-qa
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.