From bddd3f6ac6525ded2d0a63cbd45a7053cd248ea5 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 21 Nov 2025 19:28:39 +0100 Subject: [PATCH] rm test_bundle_logic.zig (#8409) This was not actually testing stuff defined outside the test. --- src/cli/main.zig | 1 - src/cli/test_bundle_logic.zig | 132 ---------------------------------- 2 files changed, 133 deletions(-) delete mode 100644 src/cli/test_bundle_logic.zig diff --git a/src/cli/main.zig b/src/cli/main.zig index abf9980567..adc5eea019 100644 --- a/src/cli/main.zig +++ b/src/cli/main.zig @@ -63,7 +63,6 @@ const Allocators = base.Allocators; const roc_interpreter_shim_lib = if (builtin.is_test) &[_]u8{} else if (builtin.target.os.tag == .windows) @embedFile("roc_interpreter_shim.lib") else @embedFile("libroc_interpreter_shim.a"); test "main cli tests" { - _ = @import("test_bundle_logic.zig"); _ = @import("libc_finder.zig"); _ = @import("test_shared_memory_system.zig"); } diff --git a/src/cli/test_bundle_logic.zig b/src/cli/test_bundle_logic.zig deleted file mode 100644 index 03a89224b4..0000000000 --- a/src/cli/test_bundle_logic.zig +++ /dev/null @@ -1,132 +0,0 @@ -//! Unit tests for the bundle CLI logic (sorting, deduplication, first arg preservation) - -const std = @import("std"); -const testing = std.testing; - -test "bundle paths - empty list defaults to main.roc" { - // Simulate the logic from rocBundle - const paths_to_use = if (0 == 0) &[_][]const u8{"main.roc"} else &[_][]const u8{}; - - try testing.expectEqual(@as(usize, 1), paths_to_use.len); - try testing.expectEqualStrings("main.roc", paths_to_use[0]); -} - -test "bundle paths - single file unchanged" { - const allocator = testing.allocator; - - var file_paths = std.ArrayList([]const u8).empty; - defer file_paths.deinit(allocator); - - try file_paths.append(allocator, "app.roc"); - - try testing.expectEqual(@as(usize, 1), file_paths.items.len); - try testing.expectEqualStrings("app.roc", file_paths.items[0]); -} - -test "bundle paths - sorting and deduplication" { - const allocator = testing.allocator; - - var file_paths = std.ArrayList([]const u8).empty; - defer file_paths.deinit(allocator); - - // Add paths in non-sorted order with duplicates - try file_paths.append(allocator, "zebra.roc"); - try file_paths.append(allocator, "apple.roc"); - try file_paths.append(allocator, "banana.roc"); - try file_paths.append(allocator, "apple.roc"); - - const first_cli_path = file_paths.items[0]; // "zebra.roc" - - // Sort - std.mem.sort([]const u8, file_paths.items, {}, struct { - fn lessThan(_: void, a: []const u8, b: []const u8) bool { - return std.mem.order(u8, a, b) == .lt; - } - }.lessThan); - - // Remove duplicates - var unique_count: usize = 0; - for (file_paths.items, 0..) |path, i| { - if (i == 0 or !std.mem.eql(u8, path, file_paths.items[i - 1])) { - file_paths.items[unique_count] = path; - unique_count += 1; - } - } - file_paths.items.len = unique_count; - - // Verify deduplication worked - try testing.expectEqual(@as(usize, 3), file_paths.items.len); - - // Ensure first CLI path stays first - if (file_paths.items.len > 1) { - var found_index: ?usize = null; - for (file_paths.items, 0..) |path, i| { - if (std.mem.eql(u8, path, first_cli_path)) { - found_index = i; - break; - } - } - - if (found_index) |idx| { - if (idx != 0) { - const temp = file_paths.items[0]; - file_paths.items[0] = file_paths.items[idx]; - file_paths.items[idx] = temp; - } - } - } - - // Verify final order - try testing.expectEqualStrings("zebra.roc", file_paths.items[0]); - try testing.expectEqualStrings("banana.roc", file_paths.items[1]); - try testing.expectEqualStrings("apple.roc", file_paths.items[2]); -} - -test "bundle paths - preserves first CLI arg with many files" { - const allocator = testing.allocator; - - var file_paths = std.ArrayList([]const u8).empty; - defer file_paths.deinit(allocator); - - // Add 8 paths with specific first - try file_paths.append(allocator, "tests/test2.roc"); - try file_paths.append(allocator, "main.roc"); - try file_paths.append(allocator, "src/app.roc"); - try file_paths.append(allocator, "src/lib.roc"); - try file_paths.append(allocator, "src/utils/helper.roc"); - try file_paths.append(allocator, "tests/test1.roc"); - try file_paths.append(allocator, "docs/readme.md"); - try file_paths.append(allocator, "config.roc"); - - const first_cli_path = file_paths.items[0]; // "tests/test2.roc" - - // Sort - std.mem.sort([]const u8, file_paths.items, {}, struct { - fn lessThan(_: void, a: []const u8, b: []const u8) bool { - return std.mem.order(u8, a, b) == .lt; - } - }.lessThan); - - // Find and move first CLI path to front - if (file_paths.items.len > 1) { - var found_index: ?usize = null; - for (file_paths.items, 0..) |path, i| { - if (std.mem.eql(u8, path, first_cli_path)) { - found_index = i; - break; - } - } - - if (found_index) |idx| { - if (idx != 0) { - const temp = file_paths.items[0]; - file_paths.items[0] = file_paths.items[idx]; - file_paths.items[idx] = temp; - } - } - } - - // Verify first path is preserved - try testing.expectEqualStrings("tests/test2.roc", file_paths.items[0]); - try testing.expectEqual(@as(usize, 8), file_paths.items.len); -}