@native-sdk/cli 0.4.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +371 -5
- package/build/ts_run.mjs +102 -0
- package/build.zig +255 -1
- package/build.zig.zon +1 -0
- package/package.json +19 -10
- package/packages/core/package-lock.json +44 -0
- package/packages/core/package.json +38 -0
- package/packages/core/rt/rt.zig +1579 -0
- package/packages/core/sdk/bytes_text_methods.d.ts +88 -0
- package/packages/core/sdk/core.ts +694 -0
- package/packages/core/sdk/events.ts +137 -0
- package/packages/core/sdk/text.ts +519 -0
- package/packages/core/src/checker.ts +1869 -0
- package/packages/core/src/cli.ts +68 -0
- package/packages/core/src/devhost.ts +291 -0
- package/packages/core/src/devhost_resolver.mjs +22 -0
- package/packages/core/src/diagnostics.ts +417 -0
- package/packages/core/src/emitter.ts +8815 -0
- package/packages/core/src/infer.ts +1515 -0
- package/packages/core/src/modules.ts +173 -0
- package/packages/core/src/ownership.ts +740 -0
- package/packages/core/src/text_polyfill.ts +337 -0
- package/packages/core/src/text_tables.ts +408 -0
- package/packages/core/src/transpile.ts +146 -0
- package/packages/core/src/typed_ast.ts +546 -0
- package/packages/core/src/types.ts +815 -0
- package/skill-data/native-ui/SKILL.md +14 -0
- package/skill-data/ts-core/SKILL.md +493 -0
- package/skill-data/zig/SKILL.md +10 -0
- package/src/app_runner/root.zig +24 -0
- package/src/app_runner/ts_core_main.zig +231 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/app_manifest/comptime_scene.zig +341 -0
- package/src/primitives/app_manifest/root.zig +5 -0
- package/src/primitives/canvas/commands.zig +14 -7
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/lazy_tls.zig +73 -0
- package/src/primitives/canvas/render_generic_resources.zig +22 -15
- package/src/primitives/canvas/root.zig +11 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +40 -32
- package/src/primitives/canvas/text_layout_cache.zig +29 -22
- package/src/primitives/canvas/text_measure_cache.zig +56 -41
- package/src/primitives/canvas/text_spans.zig +39 -26
- package/src/primitives/canvas/tokens.zig +69 -0
- package/src/primitives/canvas/ui.zig +125 -0
- package/src/primitives/canvas/ui_markup.zig +22 -3
- package/src/primitives/canvas/ui_markup_compiled.zig +97 -7
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +275 -0
- package/src/primitives/canvas/ui_markup_contract.zig +68 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +257 -2
- package/src/primitives/canvas/ui_markup_reflect.zig +214 -0
- package/src/primitives/canvas/ui_markup_view.zig +105 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +336 -0
- package/src/primitives/canvas/ui_schema.zig +8 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +309 -5
- package/src/primitives/canvas/widget_invalidation.zig +14 -7
- package/src/primitives/canvas/widget_layout.zig +138 -2
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_render.zig +25 -15
- package/src/primitives/canvas/widget_render_controls.zig +15 -9
- package/src/primitives/canvas/widget_runtime_tests.zig +44 -0
- package/src/root.zig +7 -0
- package/src/runtime/canvas_frame.zig +57 -36
- package/src/runtime/canvas_images.zig +9 -3
- package/src/runtime/canvas_widget_control_tests.zig +5 -6
- package/src/runtime/canvas_widget_runtime.zig +7 -4
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +1525 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_host_tests.zig +594 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/root.zig +18 -0
- package/src/runtime/session_replay.zig +7 -1
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_core_host.zig +1505 -0
- package/src/runtime/ts_core_host_tests.zig +1408 -0
- package/src/runtime/ts_ui_app.zig +469 -0
- package/src/runtime/ui_app.zig +189 -38
- package/src/runtime/ui_app_tests.zig +221 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view_canvas.zig +24 -17
- package/src/runtime/view_widget_tree.zig +2 -2
- package/src/tooling/codesign.zig +212 -105
- package/src/tooling/doctor.zig +78 -0
- package/src/tooling/manifest.zig +47 -0
- package/src/tooling/package.zig +435 -20
- package/src/tooling/raw_manifest.zig +15 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +777 -34
- package/src/tooling/ts_core.zig +1099 -0
- package/src/tooling/verbs.zig +105 -2
|
@@ -9,6 +9,7 @@ const app_manifest = @import("app_manifest");
|
|
|
9
9
|
const core = @import("core.zig");
|
|
10
10
|
const ui_app_model = @import("ui_app.zig");
|
|
11
11
|
const effects_mod = @import("effects.zig");
|
|
12
|
+
const clock_mod = @import("clock.zig");
|
|
12
13
|
|
|
13
14
|
const canvas_label = "fetch-canvas";
|
|
14
15
|
|
|
@@ -980,6 +981,47 @@ test "real fetch reports connection refused as connect_failed" {
|
|
|
980
981
|
try std.testing.expectEqual(@as(usize, 0), h.app_state.model.body_len);
|
|
981
982
|
}
|
|
982
983
|
|
|
984
|
+
test "a fetch whose exchange cannot start cancellably is rejected, never run inline" {
|
|
985
|
+
var h = try Harness.create();
|
|
986
|
+
defer h.destroy();
|
|
987
|
+
const fx = &h.app_state.effects;
|
|
988
|
+
// Pin the no-capacity path through the injectable seam (the real
|
|
989
|
+
// trigger — the executor refusing `std.Io.concurrent` — needs
|
|
990
|
+
// resource exhaustion). If a regression ran the exchange inline
|
|
991
|
+
// instead, this loopback connect would fail fast as
|
|
992
|
+
// `.connect_failed` and the assert below would catch the lie.
|
|
993
|
+
fx.fetch_concurrent_start = false;
|
|
994
|
+
|
|
995
|
+
var url_buffer: [128]u8 = undefined;
|
|
996
|
+
test_url = std.fmt.bufPrint(&url_buffer, "http://127.0.0.1:9/", .{}) catch unreachable;
|
|
997
|
+
test_method = .GET;
|
|
998
|
+
test_headers = &.{};
|
|
999
|
+
test_payload = null;
|
|
1000
|
+
test_timeout_ms = effects_mod.default_effect_fetch_timeout_ms;
|
|
1001
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
1002
|
+
try waitForResponse(&h);
|
|
1003
|
+
|
|
1004
|
+
// Exactly one honest `.rejected` terminal — the fetch never
|
|
1005
|
+
// started — counted through the rejection seam.
|
|
1006
|
+
try std.testing.expectEqual(effects_mod.EffectFetchOutcome.rejected, h.app_state.model.outcome.?);
|
|
1007
|
+
try std.testing.expectEqual(@as(usize, 1), h.app_state.model.rejected_count);
|
|
1008
|
+
try std.testing.expectEqual(@as(u16, 0), h.app_state.model.status);
|
|
1009
|
+
try std.testing.expectEqual(@as(usize, 0), h.app_state.model.body_len);
|
|
1010
|
+
try std.testing.expectEqual(@as(u32, 1), fx.fetch_start_rejections.load(.acquire));
|
|
1011
|
+
try std.testing.expectEqual(@as(usize, 0), h.app_state.effects.activeCount());
|
|
1012
|
+
|
|
1013
|
+
// Teardown returns promptly: no uncancelable inline exchange is
|
|
1014
|
+
// left for the unconditional fetch join to wait on.
|
|
1015
|
+
const start_ns = clock_mod.monotonicNanoseconds();
|
|
1016
|
+
fx.deinit();
|
|
1017
|
+
const elapsed_ms = (clock_mod.monotonicNanoseconds() - start_ns) / std.time.ns_per_ms;
|
|
1018
|
+
try std.testing.expect(elapsed_ms < 10_000);
|
|
1019
|
+
for (&fx.slots) |*slot| {
|
|
1020
|
+
try std.testing.expect(slot.worker_thread == null);
|
|
1021
|
+
try std.testing.expect(slot.state.load(.acquire) != .running);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
983
1025
|
test "real fetch times out against a hanging route" {
|
|
984
1026
|
var h = try Harness.create();
|
|
985
1027
|
defer h.destroy();
|
|
@@ -11,6 +11,7 @@ const app_manifest = @import("app_manifest");
|
|
|
11
11
|
const core = @import("core.zig");
|
|
12
12
|
const ui_app_model = @import("ui_app.zig");
|
|
13
13
|
const effects_mod = @import("effects.zig");
|
|
14
|
+
const clock_mod = @import("clock.zig");
|
|
14
15
|
|
|
15
16
|
const canvas_label = "file-canvas";
|
|
16
17
|
|
|
@@ -346,6 +347,16 @@ test "real executor writes a file (creating parent dirs) and reads it back" {
|
|
|
346
347
|
try h.app_state.dispatch(&h.harness.runtime, 1, .load);
|
|
347
348
|
try waitForRealResult(&h, 4);
|
|
348
349
|
try std.testing.expectEqualStrings("{\"n\":2}", h.app_state.model.bytesPrefix());
|
|
350
|
+
|
|
351
|
+
// Happy-path teardown pin: quick local ops join promptly and the
|
|
352
|
+
// abandon safety net never fires (no leak, no detached thread).
|
|
353
|
+
const fx = &h.app_state.effects;
|
|
354
|
+
fx.deinit();
|
|
355
|
+
try std.testing.expectEqual(@as(u32, 0), fx.abandoned_file_workers);
|
|
356
|
+
for (&fx.slots) |*slot| {
|
|
357
|
+
try std.testing.expect(slot.worker_thread == null);
|
|
358
|
+
try std.testing.expect(slot.state.load(.acquire) != .running);
|
|
359
|
+
}
|
|
349
360
|
}
|
|
350
361
|
|
|
351
362
|
test "real executor reports missing files as not_found" {
|
|
@@ -386,6 +397,215 @@ test "real executor cuts over-bound reads with outcome truncated" {
|
|
|
386
397
|
);
|
|
387
398
|
}
|
|
388
399
|
|
|
400
|
+
// --------------------------------------------------- bounded teardown
|
|
401
|
+
|
|
402
|
+
/// Create a FIFO at `path` (POSIX-only; callers gate on the platform).
|
|
403
|
+
/// A file write against it blocks forever inside `open(O_WRONLY)`
|
|
404
|
+
/// while no reader exists — the uninterruptible-blocking-I/O posture
|
|
405
|
+
/// the teardown deadline exists for.
|
|
406
|
+
fn makeFifo(path: []const u8) !void {
|
|
407
|
+
var command_buffer: [512]u8 = undefined;
|
|
408
|
+
const command = try std.fmt.bufPrint(&command_buffer, "mkfifo '{s}'", .{path});
|
|
409
|
+
const result = try std.process.run(std.testing.allocator, std.testing.io, .{
|
|
410
|
+
.argv = &.{ "/bin/sh", "-c", command },
|
|
411
|
+
});
|
|
412
|
+
defer std.testing.allocator.free(result.stdout);
|
|
413
|
+
defer std.testing.allocator.free(result.stderr);
|
|
414
|
+
try std.testing.expect(result.term == .exited and result.term.exited == 0);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
test "teardown abandons a file worker stuck on a reader-less FIFO and leaks its world loudly" {
|
|
418
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
419
|
+
const io = std.testing.io;
|
|
420
|
+
var tmp = std.testing.tmpDir(.{});
|
|
421
|
+
defer tmp.cleanup();
|
|
422
|
+
|
|
423
|
+
var fifo_path_buffer: [256]u8 = undefined;
|
|
424
|
+
const fifo_path = try std.fmt.bufPrint(&fifo_path_buffer, ".zig-cache/tmp/{s}/stuck.fifo", .{tmp.sub_path[0..]});
|
|
425
|
+
try makeFifo(fifo_path);
|
|
426
|
+
|
|
427
|
+
var h = try Harness.create();
|
|
428
|
+
defer h.destroy();
|
|
429
|
+
const fx = &h.app_state.effects;
|
|
430
|
+
// Tiny injected budget, interruption disabled: this test pins the
|
|
431
|
+
// SAFETY NET (abandon-and-leak). The interruption path that
|
|
432
|
+
// normally converges first has its own test below.
|
|
433
|
+
fx.file_join_deadline_ms = 300;
|
|
434
|
+
fx.file_join_interrupt = false;
|
|
435
|
+
|
|
436
|
+
test_path = fifo_path;
|
|
437
|
+
test_bytes = "never delivered";
|
|
438
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .save);
|
|
439
|
+
// Let the worker reach the blocking open. Not required for the
|
|
440
|
+
// abandon to fire — with interruption off, any still-running
|
|
441
|
+
// posture past the deadline is abandoned — but it exercises the
|
|
442
|
+
// real blocked shape.
|
|
443
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(50), .awake);
|
|
444
|
+
|
|
445
|
+
const start_ns = clock_mod.monotonicNanoseconds();
|
|
446
|
+
fx.deinit();
|
|
447
|
+
const elapsed_ms = (clock_mod.monotonicNanoseconds() - start_ns) / std.time.ns_per_ms;
|
|
448
|
+
|
|
449
|
+
// Teardown returned on the budget's order of magnitude (generous
|
|
450
|
+
// bound for congested runners) instead of hanging behind the FIFO
|
|
451
|
+
// forever...
|
|
452
|
+
try std.testing.expect(elapsed_ms < 10_000);
|
|
453
|
+
// ...and abandoned exactly the stuck worker, loudly through the
|
|
454
|
+
// counter seam, leaving no joinable thread and no running slot —
|
|
455
|
+
// the owner may free the channel's memory right now.
|
|
456
|
+
try std.testing.expectEqual(@as(u32, 1), fx.abandoned_file_workers);
|
|
457
|
+
for (&fx.slots) |*slot| {
|
|
458
|
+
try std.testing.expect(slot.worker_thread == null);
|
|
459
|
+
try std.testing.expect(slot.state.load(.acquire) != .running);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// The process is healthy after the leak: a fresh channel runs a
|
|
463
|
+
// real file round trip and its own safety net stays quiet.
|
|
464
|
+
var h2 = try Harness.create();
|
|
465
|
+
defer h2.destroy();
|
|
466
|
+
var path_buffer: [256]u8 = undefined;
|
|
467
|
+
test_path = try std.fmt.bufPrint(&path_buffer, ".zig-cache/tmp/{s}/healthy.json", .{tmp.sub_path[0..]});
|
|
468
|
+
test_bytes = "{\"alive\":true}";
|
|
469
|
+
try h2.app_state.dispatch(&h2.harness.runtime, 1, .save);
|
|
470
|
+
try waitForRealResult(&h2, 1);
|
|
471
|
+
try std.testing.expectEqual(effects_mod.EffectFileOutcome.ok, h2.app_state.model.last_outcome.?);
|
|
472
|
+
try std.testing.expectEqual(@as(u32, 0), h2.app_state.effects.abandoned_file_workers);
|
|
473
|
+
|
|
474
|
+
// Wake the abandoned worker under the leak invariant: opening the
|
|
475
|
+
// FIFO's read end completes its blocked open; it performs its
|
|
476
|
+
// write against its (leaked, still-valid) context and buffer,
|
|
477
|
+
// closes the FIFO, finds itself abandoned, and exits without
|
|
478
|
+
// touching the torn-down channel — if the leak were not honored,
|
|
479
|
+
// this is where a use-after-free would crash the test. Draining to
|
|
480
|
+
// EOF keeps the read end open across the worker's write (a write
|
|
481
|
+
// into a reader-less pipe raises SIGPIPE, and the io's no-op
|
|
482
|
+
// handler is not installed between tests) and proves the worker
|
|
483
|
+
// really woke: EOF only arrives once it opened and closed the
|
|
484
|
+
// write end.
|
|
485
|
+
var reader = try std.Io.Dir.cwd().openFile(io, fifo_path, .{});
|
|
486
|
+
defer reader.close(io);
|
|
487
|
+
var drain_buffer: [128]u8 = undefined;
|
|
488
|
+
while (true) {
|
|
489
|
+
const read_slices: [1][]u8 = .{&drain_buffer};
|
|
490
|
+
const count = reader.readStreaming(io, &read_slices) catch break;
|
|
491
|
+
if (count == 0) break;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
test "an abandoned file worker survives the owner's allocator dying: its leak is process-lived only" {
|
|
496
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
497
|
+
const io = std.testing.io;
|
|
498
|
+
var tmp = std.testing.tmpDir(.{});
|
|
499
|
+
defer tmp.cleanup();
|
|
500
|
+
|
|
501
|
+
var fifo_path_buffer: [256]u8 = undefined;
|
|
502
|
+
const fifo_path = try std.fmt.bufPrint(&fifo_path_buffer, ".zig-cache/tmp/{s}/arena.fifo", .{tmp.sub_path[0..]});
|
|
503
|
+
try makeFifo(fifo_path);
|
|
504
|
+
|
|
505
|
+
// The channel — and every caller-side allocation it makes — lives
|
|
506
|
+
// in an arena backed by the leak-checking testing allocator and is
|
|
507
|
+
// deinitialized right after teardown: the exact owner-lifetime
|
|
508
|
+
// posture the abandon leak must survive. The channel struct itself
|
|
509
|
+
// sits in the arena too, so even the worker's `self` pointer dies
|
|
510
|
+
// with the owner.
|
|
511
|
+
const Channel = effects_mod.Effects(FileMsg);
|
|
512
|
+
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
|
|
513
|
+
var arena_live = true;
|
|
514
|
+
defer if (arena_live) arena.deinit();
|
|
515
|
+
const fx = try arena.allocator().create(Channel);
|
|
516
|
+
fx.* = Channel.init(arena.allocator());
|
|
517
|
+
// Tiny injected budget, interruption disabled: pin the
|
|
518
|
+
// abandon-and-leak safety net, exactly like the loud-leak test.
|
|
519
|
+
fx.file_join_deadline_ms = 300;
|
|
520
|
+
fx.file_join_interrupt = false;
|
|
521
|
+
|
|
522
|
+
fx.writeFile(.{ .key = 1, .path = fifo_path, .bytes = "never delivered", .on_result = null });
|
|
523
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(50), .awake);
|
|
524
|
+
|
|
525
|
+
fx.deinit();
|
|
526
|
+
try std.testing.expectEqual(@as(u32, 1), fx.abandoned_file_workers);
|
|
527
|
+
|
|
528
|
+
// Kill the owner's allocator: everything the channel ever got from
|
|
529
|
+
// it — including the channel struct — is gone. The abandoned
|
|
530
|
+
// worker must not notice: all it can still reach (its context,
|
|
531
|
+
// that context's buffer, the executor io) is `process_allocator`
|
|
532
|
+
// storage.
|
|
533
|
+
arena.deinit();
|
|
534
|
+
arena_live = false;
|
|
535
|
+
|
|
536
|
+
// Wake the abandoned worker under that invariant: opening the
|
|
537
|
+
// FIFO's read end completes its blocked open; it writes through
|
|
538
|
+
// its process-lived context and buffer, finds itself abandoned,
|
|
539
|
+
// and exits without touching the dead arena — if any of its
|
|
540
|
+
// reachable memory were caller-allocated, this walk is where the
|
|
541
|
+
// use-after-free would crash the test. Draining to EOF keeps the
|
|
542
|
+
// read end open across the worker's write and proves the worker
|
|
543
|
+
// really woke.
|
|
544
|
+
var reader = try std.Io.Dir.cwd().openFile(io, fifo_path, .{});
|
|
545
|
+
defer reader.close(io);
|
|
546
|
+
var drain_buffer: [128]u8 = undefined;
|
|
547
|
+
while (true) {
|
|
548
|
+
const read_slices: [1][]u8 = .{&drain_buffer};
|
|
549
|
+
const count = reader.readStreaming(io, &read_slices) catch break;
|
|
550
|
+
if (count == 0) break;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// And the happy path still frees everything through the same
|
|
554
|
+
// seams: a fresh channel backed DIRECTLY by the testing allocator
|
|
555
|
+
// runs a real write to completion and tears down joined — the
|
|
556
|
+
// leak check at test end guards the caller-side allocations, and
|
|
557
|
+
// `joinWorker`/`deinit` return the context, worker buffer, and
|
|
558
|
+
// executor io to `process_allocator`.
|
|
559
|
+
var healthy = Channel.init(std.testing.allocator);
|
|
560
|
+
defer healthy.deinit();
|
|
561
|
+
var path_buffer: [256]u8 = undefined;
|
|
562
|
+
const healthy_path = try std.fmt.bufPrint(&path_buffer, ".zig-cache/tmp/{s}/healthy.json", .{tmp.sub_path[0..]});
|
|
563
|
+
healthy.writeFile(.{ .key = 2, .path = healthy_path, .bytes = "{\"alive\":true}", .on_result = null });
|
|
564
|
+
var waited_ms: usize = 0;
|
|
565
|
+
while (waited_ms < 20_000) : (waited_ms += 10) {
|
|
566
|
+
if (healthy.hasPending()) break;
|
|
567
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(10), .awake);
|
|
568
|
+
}
|
|
569
|
+
try std.testing.expect(healthy.hasPending());
|
|
570
|
+
healthy.deinit();
|
|
571
|
+
try std.testing.expectEqual(@as(u32, 0), healthy.abandoned_file_workers);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
test "teardown interrupts a file worker stuck on a reader-less FIFO and joins it with no leak" {
|
|
575
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
576
|
+
const io = std.testing.io;
|
|
577
|
+
var tmp = std.testing.tmpDir(.{});
|
|
578
|
+
defer tmp.cleanup();
|
|
579
|
+
|
|
580
|
+
var fifo_path_buffer: [256]u8 = undefined;
|
|
581
|
+
const fifo_path = try std.fmt.bufPrint(&fifo_path_buffer, ".zig-cache/tmp/{s}/interrupted.fifo", .{tmp.sub_path[0..]});
|
|
582
|
+
try makeFifo(fifo_path);
|
|
583
|
+
|
|
584
|
+
var h = try Harness.create();
|
|
585
|
+
defer h.destroy();
|
|
586
|
+
const fx = &h.app_state.effects;
|
|
587
|
+
// Interruption stays on (the default): the best-effort cancel at
|
|
588
|
+
// the halfway mark must interrupt the blocked open and JOIN the
|
|
589
|
+
// worker — the abandon safety net must never fire here.
|
|
590
|
+
fx.file_join_deadline_ms = 2_000;
|
|
591
|
+
|
|
592
|
+
test_path = fifo_path;
|
|
593
|
+
test_bytes = "never delivered";
|
|
594
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .save);
|
|
595
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(50), .awake);
|
|
596
|
+
|
|
597
|
+
fx.deinit();
|
|
598
|
+
|
|
599
|
+
// Joined, not leaked: the syscall interruption converged the
|
|
600
|
+
// worker inside the deadline (deinit is deadline-bounded either
|
|
601
|
+
// way, so reaching these asserts already proves it returned).
|
|
602
|
+
try std.testing.expectEqual(@as(u32, 0), fx.abandoned_file_workers);
|
|
603
|
+
for (&fx.slots) |*slot| {
|
|
604
|
+
try std.testing.expect(slot.worker_thread == null);
|
|
605
|
+
try std.testing.expect(slot.state.load(.acquire) != .running);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
389
609
|
test "a cancel racing a finished file effect still reports one cancelled terminal" {
|
|
390
610
|
var tmp = std.testing.tmpDir(.{});
|
|
391
611
|
defer tmp.cleanup();
|