Skip to content

Commit

Permalink
get node:fs tests passing part 1 (#16270)
Browse files Browse the repository at this point in the history
  • Loading branch information
paperclover authored Jan 15, 2025
1 parent 4e193b0 commit 834ad11
Show file tree
Hide file tree
Showing 126 changed files with 5,123 additions and 2,401 deletions.
4 changes: 2 additions & 2 deletions cmake/tools/SetupLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ if(APPLE)
endif()
endif()

list(APPEND LLVM_PATHS ${HOMEBREW_PREFIX}/opt/llvm/bin)

if(USE_LLVM_VERSION)
list(APPEND LLVM_PATHS ${HOMEBREW_PREFIX}/opt/llvm@${LLVM_VERSION_MAJOR}/bin)
endif()

list(APPEND LLVM_PATHS ${HOMEBREW_PREFIX}/opt/llvm/bin)
endif()

if(UNIX)
Expand Down
22 changes: 0 additions & 22 deletions jsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions src/bake/production.zig
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,6 @@ export fn BakeProdLoad(pt: *PerThread, key: bun.String) bun.String {
if (pt.module_map.get(utf8.slice())) |value| {
return pt.bundled_outputs[value.get()].value.toBunString();
}
for (pt.module_map.keys()) |keys| {
std.debug.print("key that does exist: {s}\n", .{keys});
}
return bun.String.dead;
}

Expand Down
150 changes: 76 additions & 74 deletions src/bun.js/ConsoleObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3262,86 +3262,88 @@ pub const Formatter = struct {
else
bun.asByteSlice(@tagName(arrayBuffer.typed_array_type)),
);
if (slice.len == 0) {
writer.print("({d}) []", .{arrayBuffer.len});
return;
}
writer.print("({d}) [ ", .{arrayBuffer.len});

if (slice.len > 0) {
switch (jsType) {
.Int8Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
i8,
@as([]align(std.meta.alignment([]i8)) i8, @alignCast(std.mem.bytesAsSlice(i8, slice))),
enable_ansi_colors,
),
.Int16Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
i16,
@as([]align(std.meta.alignment([]i16)) i16, @alignCast(std.mem.bytesAsSlice(i16, slice))),
enable_ansi_colors,
),
.Uint16Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
u16,
@as([]align(std.meta.alignment([]u16)) u16, @alignCast(std.mem.bytesAsSlice(u16, slice))),
enable_ansi_colors,
),
.Int32Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
i32,
@as([]align(std.meta.alignment([]i32)) i32, @alignCast(std.mem.bytesAsSlice(i32, slice))),
enable_ansi_colors,
),
.Uint32Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
u32,
@as([]align(std.meta.alignment([]u32)) u32, @alignCast(std.mem.bytesAsSlice(u32, slice))),
enable_ansi_colors,
),
.Float16Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
f16,
@as([]align(std.meta.alignment([]f16)) f16, @alignCast(std.mem.bytesAsSlice(f16, slice))),
enable_ansi_colors,
),
.Float32Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
f32,
@as([]align(std.meta.alignment([]f32)) f32, @alignCast(std.mem.bytesAsSlice(f32, slice))),
enable_ansi_colors,
),
.Float64Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
f64,
@as([]align(std.meta.alignment([]f64)) f64, @alignCast(std.mem.bytesAsSlice(f64, slice))),
enable_ansi_colors,
),
.BigInt64Array => this.writeTypedArray(
switch (jsType) {
.Int8Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
i8,
@alignCast(std.mem.bytesAsSlice(i8, slice)),
enable_ansi_colors,
),
.Int16Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
i16,
@alignCast(std.mem.bytesAsSlice(i16, slice)),
enable_ansi_colors,
),
.Uint16Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
u16,
@alignCast(std.mem.bytesAsSlice(u16, slice)),
enable_ansi_colors,
),
.Int32Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
i32,
@alignCast(std.mem.bytesAsSlice(i32, slice)),
enable_ansi_colors,
),
.Uint32Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
u32,
@alignCast(std.mem.bytesAsSlice(u32, slice)),
enable_ansi_colors,
),
.Float16Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
f16,
@alignCast(std.mem.bytesAsSlice(f16, slice)),
enable_ansi_colors,
),
.Float32Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
f32,
@alignCast(std.mem.bytesAsSlice(f32, slice)),
enable_ansi_colors,
),
.Float64Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
f64,
@alignCast(std.mem.bytesAsSlice(f64, slice)),
enable_ansi_colors,
),
.BigInt64Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
i64,
@alignCast(std.mem.bytesAsSlice(i64, slice)),
enable_ansi_colors,
),
.BigUint64Array => {
this.writeTypedArray(
*@TypeOf(writer),
&writer,
i64,
@as([]align(std.meta.alignment([]i64)) i64, @alignCast(std.mem.bytesAsSlice(i64, slice))),
u64,
@as([]align(std.meta.alignment([]u64)) u64, @alignCast(std.mem.bytesAsSlice(u64, slice))),
enable_ansi_colors,
),
.BigUint64Array => {
this.writeTypedArray(
*@TypeOf(writer),
&writer,
u64,
@as([]align(std.meta.alignment([]u64)) u64, @alignCast(std.mem.bytesAsSlice(u64, slice))),
enable_ansi_colors,
);
},
);
},

// Uint8Array, Uint8ClampedArray, DataView, ArrayBuffer
else => this.writeTypedArray(*@TypeOf(writer), &writer, u8, slice, enable_ansi_colors),
}
// Uint8Array, Uint8ClampedArray, DataView, ArrayBuffer
else => this.writeTypedArray(*@TypeOf(writer), &writer, u8, slice, enable_ansi_colors),
}

writer.writeAll(" ]");
Expand Down
14 changes: 4 additions & 10 deletions src/bun.js/api/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2709,18 +2709,14 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
file.pathlike.fd
else switch (bun.sys.open(file.pathlike.path.sliceZ(&file_buf), bun.O.RDONLY | bun.O.NONBLOCK | bun.O.CLOEXEC, 0)) {
.result => |_fd| _fd,
.err => |err| return this.runErrorHandler(err.withPath(file.pathlike.path.slice()).toSystemError().toErrorInstance(
globalThis,
)),
.err => |err| return this.runErrorHandler(err.withPath(file.pathlike.path.slice()).toJSC(globalThis)),
};

// stat only blocks if the target is a file descriptor
const stat: bun.Stat = switch (bun.sys.fstat(fd)) {
.result => |result| result,
.err => |err| {
this.runErrorHandler(err.withPathLike(file.pathlike).toSystemError().toErrorInstance(
globalThis,
));
this.runErrorHandler(err.withPathLike(file.pathlike).toJSC(globalThis));
if (auto_close) {
_ = bun.sys.close(fd);
}
Expand Down Expand Up @@ -2757,11 +2753,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
.errno = @as(bun.sys.Error.Int, @intCast(@intFromEnum(std.posix.E.INVAL))),
.syscall = .sendfile,
};
var sys = err.withPathLike(file.pathlike).toSystemError();
var sys = err.withPathLike(file.pathlike).toShellSystemError();
sys.message = bun.String.static("File must be regular or FIFO");
this.runErrorHandler(sys.toErrorInstance(
globalThis,
));
this.runErrorHandler(sys.toErrorInstance(globalThis));
return;
}
}
Expand Down
30 changes: 0 additions & 30 deletions src/bun.js/bindings/JSPropertyIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,6 @@ extern "C" JSPropertyIterator* Bun__JSPropertyIterator__create(JSC::JSGlobalObje
return JSPropertyIterator::create(vm, array.releaseData());
}

// The only non-own property that we sometimes want to get is the code property.
extern "C" EncodedJSValue Bun__JSPropertyIterator__getCodeProperty(JSPropertyIterator* iter, JSC::JSGlobalObject* globalObject, JSC::JSObject* object)
{
if (UNLIKELY(!iter)) {
return {};
}

auto& vm = iter->vm;
auto scope = DECLARE_THROW_SCOPE(vm);
RETURN_IF_EXCEPTION(scope, {});
if (UNLIKELY(object->type() == JSC::ProxyObjectType)) {
return {};
}

auto& builtinNames = WebCore::builtinNames(vm);

PropertySlot slot(object, PropertySlot::InternalMethodType::VMInquiry, vm.ptr());
if (!object->getNonIndexPropertySlot(globalObject, builtinNames.codePublicName(), slot)) {
return {};
}

if (slot.isAccessor() || slot.isCustom()) {
return {};
}

RETURN_IF_EXCEPTION(scope, {});

return JSValue::encode(slot.getPureResult());
}

extern "C" size_t Bun__JSPropertyIterator__getLongestPropertyName(JSPropertyIterator* iter, JSC::JSGlobalObject* globalObject, JSC::JSObject* object)
{
size_t longest = 0;
Expand Down
25 changes: 0 additions & 25 deletions src/bun.js/bindings/JSPropertyIterator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extern "C" fn Bun__JSPropertyIterator__getNameAndValueNonObservable(iter: ?*anyo
extern "C" fn Bun__JSPropertyIterator__getName(iter: ?*anyopaque, propertyName: *bun.String, i: usize) void;
extern "C" fn Bun__JSPropertyIterator__deinit(iter: ?*anyopaque) void;
extern "C" fn Bun__JSPropertyIterator__getLongestPropertyName(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque) usize;
extern "C" fn Bun__JSPropertyIterator__getCodeProperty(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque) JSC.JSValue;
pub const JSPropertyIteratorOptions = struct {
skip_empty_name: bool,
include_value: bool,
Expand All @@ -27,7 +26,6 @@ pub fn JSPropertyIterator(comptime options: JSPropertyIteratorOptions) type {
globalObject: *JSC.JSGlobalObject,
object: *JSC.JSCell = undefined,
value: JSC.JSValue = .zero,
tried_code_property: bool = false,

pub fn getLongestPropertyName(this: *@This()) usize {
if (this.impl == null) return 0;
Expand Down Expand Up @@ -60,7 +58,6 @@ pub fn JSPropertyIterator(comptime options: JSPropertyIteratorOptions) type {
pub fn reset(this: *@This()) void {
this.iter_i = 0;
this.i = 0;
this.tried_code_property = false;
}

/// The bun.String returned has not incremented it's reference count.
Expand Down Expand Up @@ -107,27 +104,5 @@ pub fn JSPropertyIterator(comptime options: JSPropertyIteratorOptions) type {

unreachable;
}

/// "code" is not always an own property, and we want to get it without risking exceptions.
pub fn getCodeProperty(this: *@This()) ?bun.String {
if (comptime !options.include_value) {
@compileError("TODO");
}

if (this.tried_code_property) {
return null;
}

this.tried_code_property = true;

const current = Bun__JSPropertyIterator__getCodeProperty(this.impl, this.globalObject, this.object);
if (current == .zero) {
return null;
}
current.ensureStillAlive();
this.value = current;

return bun.String.static("code");
}
};
}
Loading

0 comments on commit 834ad11

Please sign in to comment.