From 133b2be3fcc51405a03f08859741f89b3113fcff Mon Sep 17 00:00:00 2001 From: "Nurul Huda (Apon)" Date: Thu, 16 Jul 2026 06:46:07 +0600 Subject: [PATCH] refactor: mv example to test --- .github/workflows/ci.yml | 2 +- build.zig | 50 +----- test/SPEC.md | 298 -------------------------------- {example => test}/build.zig | 0 {example => test}/build.zig.zon | 0 {example => test}/src/main.mjs | 0 {example => test}/src/main.zig | 0 {example => test}/src/root.zig | 0 {example => test}/src/wasm.zig | 0 9 files changed, 9 insertions(+), 341 deletions(-) delete mode 100644 test/SPEC.md rename {example => test}/build.zig (100%) rename {example => test}/build.zig.zon (100%) rename {example => test}/src/main.mjs (100%) rename {example => test}/src/main.zig (100%) rename {example => test}/src/root.zig (100%) rename {example => test}/src/wasm.zig (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a8628d..62d8e4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: version: 0.17.0-dev.1398+cb5635714 - name: Build and run project - run: cd example && zig build run + run: cd test && zig build run test: name: Test (${{ matrix.os }}) diff --git a/build.zig b/build.zig index 678726c..9c323cf 100644 --- a/build.zig +++ b/build.zig @@ -3,17 +3,16 @@ const std = @import("std"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const is_freestanding = target.result.os.tag == .freestanding; - const force_build_rust = b.option(bool, "build-rust", "Always build Rust library from source") orelse false; // --- Rust C ABI & Pre-built via temporal-rs subpackage --- // + const build_rust = b.option(bool, "build-rust", "Build Rust library from source"); const libtemporal = b.dependency("libtemporal", .{ .target = target, .optimize = optimize, - .@"build-rust" = force_build_rust, + .@"build-rust" = build_rust, }); - // --- Zig Module: temporalz --- // + // --- Module: temporalz --- // const mod = b.addModule("temporalz", .{ .root_source_file = b.path("src/root.zig"), .target = target, @@ -21,40 +20,21 @@ pub fn build(b: *std.Build) !void { }); mod.addImport("libtemporal", libtemporal.module("libtemporal")); - // --- Zig Executable: temporalz --- // - const exe = b.addExecutable(.{ - .name = "temporalz", - .root_module = b.createModule(.{ - .root_source_file = if (is_freestanding) - b.path("example/src/wasm.zig") - else - b.path("example/src/main.zig"), - .target = target, - .optimize = optimize, - .imports = &.{ - .{ .name = "temporalz", .module = mod }, - }, - }), - }); - exe.root_module.link_libc = !is_freestanding; - exe.rdynamic = is_freestanding; - b.installArtifact(exe); - - // --- Steps: Run --- // + // --- Step: run --- // { - const run_step = b.step("run", "Run the example project"); + const run_step = b.step("run", "Run the test project"); const run_cmd = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "run", b.fmt("-Dtarget={s}", .{try target.result.zigTriple(b.allocator)}), }); - run_cmd.setCwd(b.path("example")); + run_cmd.setCwd(b.path("test")); run_cmd.addPassthruArgs(); run_step.dependOn(&run_cmd.step); } - // --- Steps: Docs --- // + // --- Step: docs --- // { const docs_step = b.step("docs", "Build the temporalz docs"); const docs_obj = b.addObject(.{ .name = "temporalz", .root_module = mod }); @@ -67,7 +47,7 @@ pub fn build(b: *std.Build) !void { }).step); } - // --- Steps: Test --- // + // --- Step: test --- // { const test_step = b.step("test", "Run tests"); const mod_tests = b.addTest(.{ @@ -77,20 +57,6 @@ pub fn build(b: *std.Build) !void { .mode = .simple, }, }); - mod_tests.root_module.link_libc = !is_freestanding; test_step.dependOn(&b.addRunArtifact(mod_tests).step); - if (!is_freestanding) { - const exe_tests = b.addTest(.{ .root_module = exe.root_module }); - test_step.dependOn(&b.addRunArtifact(exe_tests).step); - } - } - - // --- Steps: test-262 --- // - { - const test262_step = b.step("test262", "Run test-262 tests"); - const run_cmd = b.addSystemCommand(&.{ "node", "test/test262/runner.mjs" }); - run_cmd.addPassthruArgs(); - run_cmd.step.dependOn(b.getInstallStep()); - test262_step.dependOn(&run_cmd.step); } } diff --git a/test/SPEC.md b/test/SPEC.md deleted file mode 100644 index fe112ac..0000000 --- a/test/SPEC.md +++ /dev/null @@ -1,298 +0,0 @@ -Temporal.Duration -Temporal.Instant -Temporal.Now -Temporal.PlainDate -Temporal.PlainDateTime -Temporal.PlainMonthDay -Temporal.PlainTime -Temporal.PlainYearMonth -Temporal.ZonedDateTime - -Temporal.Duration -Constructor -Temporal.Duration() -Static methods -compare() -from() -Instance methods -abs() -add() -negated() -round() -subtract() -toJSON() -toLocaleString() -toString() -total() -valueOf() -with() -Instance properties -blank -days -hours -microseconds -milliseconds -minutes -months -nanoseconds -seconds -sign -weeks -years - -Temporal.Instant -Constructor -Temporal.Instant() -Experimental -Static methods -compare() -from() -fromEpochMilliseconds() -fromEpochNanoseconds() -Instance methods -add() -equals() -round() -since() -subtract() -toJSON() -toLocaleString() -toString() -toZonedDateTimeISO() -until() -valueOf() -Instance properties -epochMilliseconds -epochNanoseconds - -Temporal.Now -Static methods -instant() -plainDateISO() -plainDateTimeISO() -plainTimeISO() -timeZoneId() -zonedDateTimeISO() - -Temporal.PlainDate -Constructor -Temporal.PlainDate() -Experimental -Static methods -compare() -from() -Instance methods -add() -equals() -since() -subtract() -toJSON() -toLocaleString() -toPlainDateTime() -toPlainMonthDay() -toPlainYearMonth() -toString() -toZonedDateTime() -until() -valueOf() -with() -withCalendar() -Instance properties -calendarId -day -dayOfWeek -dayOfYear -daysInMonth -daysInWeek -daysInYear -era -eraYear -inLeapYear -month -monthCode -monthsInYear -weekOfYear -year -yearOfWeek - -Temporal.PlainDateTime -Constructor -Temporal.PlainDateTime() -Experimental -Static methods -compare() -from() -Instance methods -add() -equals() -round() -since() -subtract() -toJSON() -toLocaleString() -toPlainDate() -toPlainTime() -toString() -toZonedDateTime() -until() -valueOf() -with() -withCalendar() -withPlainTime() -Instance properties -calendarId -day -dayOfWeek -dayOfYear -daysInMonth -daysInWeek -daysInYear -era -eraYear -hour -inLeapYear -microsecond -millisecond -minute -month -monthCode -monthsInYear -nanosecond -second -weekOfYear -year -yearOfWeek - -Temporal.PlainMonthDay -Constructor -Temporal.PlainMonthDay() -Experimental -Static methods -from() -Instance methods -equals() -toJSON() -toLocaleString() -toPlainDate() -toString() -valueOf() -with() -Instance properties -calendarId -day -monthCode - -Temporal.PlainTime -Constructor -Temporal.PlainTime() -Static methods -compare() -from() -Instance methods -add() -equals() -round() -since() -subtract() -toJSON() -toLocaleString() -toString() -until() -valueOf() -with() -Instance properties -hour -microsecond -millisecond -minute -nanosecond -second - -Temporal.PlainYearMonth -Constructor -Temporal.PlainYearMonth() -Experimental -Static methods -compare() -from() -Instance methods -add() -equals() -since() -subtract() -toJSON() -toLocaleString() -toPlainDate() -toString() -until() -valueOf() -with() -Instance properties -calendarId -daysInMonth -daysInYear -era -eraYear -inLeapYear -month -monthCode -monthsInYear -year - -Temporal.ZonedDateTime -Constructor -Temporal.ZonedDateTime() -Experimental -Static methods -compare() -from() -Instance methods -add() -equals() -getTimeZoneTransition() -round() -since() -startOfDay() -subtract() -toInstant() -toJSON() -toLocaleString() -toPlainDate() -toPlainDateTime() -toPlainTime() -toString() -until() -valueOf() -with() -withCalendar() -withPlainTime() -withTimeZone() -Instance properties -calendarId -day -dayOfWeek -dayOfYear -daysInMonth -daysInWeek -daysInYear -epochMilliseconds -epochNanoseconds -era -eraYear -hour -hoursInDay -inLeapYear -microsecond -millisecond -minute -month -monthCode -monthsInYear -nanosecond -offset -offsetNanoseconds -second -timeZoneId -weekOfYear -year -yearOfWeek diff --git a/example/build.zig b/test/build.zig similarity index 100% rename from example/build.zig rename to test/build.zig diff --git a/example/build.zig.zon b/test/build.zig.zon similarity index 100% rename from example/build.zig.zon rename to test/build.zig.zon diff --git a/example/src/main.mjs b/test/src/main.mjs similarity index 100% rename from example/src/main.mjs rename to test/src/main.mjs diff --git a/example/src/main.zig b/test/src/main.zig similarity index 100% rename from example/src/main.zig rename to test/src/main.zig diff --git a/example/src/root.zig b/test/src/root.zig similarity index 100% rename from example/src/root.zig rename to test/src/root.zig diff --git a/example/src/wasm.zig b/test/src/wasm.zig similarity index 100% rename from example/src/wasm.zig rename to test/src/wasm.zig