rm test_bundle_logic.zig (#8409)

This was not actually testing stuff defined outside the test.
This commit is contained in:
Anton-4 2025-11-21 19:28:39 +01:00 committed by GitHub
parent 4d8fd89fbc
commit bddd3f6ac6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 0 additions and 133 deletions

View file

@ -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");
}

View file

@ -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);
}