-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_file.zig
42 lines (39 loc) · 1.37 KB
/
test_file.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const std = @import("std");
const vaxis = @import("vaxis");
const KnownFolders = @import("known-folders");
const Flow = @import("flow.zig").Flow;
pub const known_folders_config: KnownFolders.KnownFolderConfig = .{
.xdg_force_default = false,
.xdg_on_mac = true,
};
/// Keep our main function small. Typically handling arg parsing and initialization only
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer {
const deinit_status = gpa.deinit();
//fail test; can't try in defer as defer is executed after we return
if (deinit_status == .leak) {
std.log.err("memory leak", .{});
}
}
const allocator = gpa.allocator();
const args = try std.process.argsAlloc(allocator);
if (args.len < 2) {
std.process.argsFree(allocator, args);
std.log.err("Usage: flow <file path>\n", .{});
return;
}
const cwd_path = try std.fs.cwd().realpathAlloc(allocator, ".");
const file_path = try std.fs.path.resolve(allocator, &.{ cwd_path, args[1] });
defer allocator.free(file_path);
allocator.free(cwd_path);
std.process.argsFree(allocator, args);
// Initialize our application
var app = try Flow.init(allocator, file_path);
defer app.deinit();
// Run the application
try app.run();
}
test "refAllDecls" {
@import("std").testing.refAllDecls(@This());
}