mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
wpt: use fs.path.join
This commit is contained in:
@@ -10,6 +10,8 @@ const Loop = jsruntime.Loop;
|
|||||||
const DOM = @import("dom.zig");
|
const DOM = @import("dom.zig");
|
||||||
const HTMLElem = @import("html/elements.zig");
|
const HTMLElem = @import("html/elements.zig");
|
||||||
|
|
||||||
|
const fspath = std.fs.path;
|
||||||
|
|
||||||
const wpt_dir = "tests/wpt";
|
const wpt_dir = "tests/wpt";
|
||||||
|
|
||||||
// FileLoader loads files content from the filesystem.
|
// FileLoader loads files content from the filesystem.
|
||||||
@@ -36,7 +38,7 @@ const FileLoader = struct {
|
|||||||
return self.files.get(name).?;
|
return self.files.get(name).?;
|
||||||
}
|
}
|
||||||
fn load(self: *FileLoader, name: []const u8) !void {
|
fn load(self: *FileLoader, name: []const u8) !void {
|
||||||
const filename = try std.mem.concat(self.alloc, u8, &.{ self.path, name });
|
const filename = try fspath.join(self.alloc, &.{ self.path, name });
|
||||||
defer self.alloc.free(filename);
|
defer self.alloc.free(filename);
|
||||||
var file = try std.fs.cwd().openFile(filename, .{});
|
var file = try std.fs.cwd().openFile(filename, .{});
|
||||||
defer file.close();
|
defer file.close();
|
||||||
@@ -160,7 +162,7 @@ fn runWPT(arena: *std.heap.ArenaAllocator, comptime apis: []jsruntime.API, f: []
|
|||||||
const html_doc = try parser.documentHTMLParseFromFileAlloc(alloc, f);
|
const html_doc = try parser.documentHTMLParseFromFileAlloc(alloc, f);
|
||||||
const doc = parser.documentHTMLToDocument(html_doc);
|
const doc = parser.documentHTMLToDocument(html_doc);
|
||||||
|
|
||||||
const dirname = std.fs.path.dirname(f[wpt_dir.len..]) orelse unreachable;
|
const dirname = fspath.dirname(f[wpt_dir.len..]) orelse unreachable;
|
||||||
|
|
||||||
// create JS env
|
// create JS env
|
||||||
var loop = try Loop.init(alloc);
|
var loop = try Loop.init(alloc);
|
||||||
@@ -220,7 +222,7 @@ fn runWPT(arena: *std.heap.ArenaAllocator, comptime apis: []jsruntime.API, f: []
|
|||||||
var path = src;
|
var path = src;
|
||||||
if (!std.mem.startsWith(u8, src, "/")) {
|
if (!std.mem.startsWith(u8, src, "/")) {
|
||||||
// no need to free path, thanks to the arena.
|
// no need to free path, thanks to the arena.
|
||||||
path = try std.fs.path.join(alloc, &.{ "/", dirname, path });
|
path = try fspath.join(alloc, &.{ "/", dirname, path });
|
||||||
}
|
}
|
||||||
|
|
||||||
res = try evalJS(js_env, alloc, try loader.get(path), src);
|
res = try evalJS(js_env, alloc, try loader.get(path), src);
|
||||||
@@ -282,6 +284,6 @@ fn findWPTTests(allocator: std.mem.Allocator, path: []const u8, list: *std.Array
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try list.append(try std.fs.path.join(allocator, &.{ path, entry.path }));
|
try list.append(try fspath.join(allocator, &.{ path, entry.path }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user