Skip to content

Commit

Permalink
node: fix all of test-event-emitter (#16009)
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro authored Dec 27, 2024
1 parent 19675f4 commit 4bcc5b2
Show file tree
Hide file tree
Showing 65 changed files with 1,732 additions and 403 deletions.
41 changes: 41 additions & 0 deletions scripts/check-node-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# How to use this script:
# 1. Pick a module from node's standard library (e.g. 'assert', 'fs')
# 2. Copy over relevant tests from node's parallel test suite into test/js/node/test/parallel
# 3. Run this script, e.g. `./scripts/check-node.sh fs`
# 4. Tests that passed get staged for commit

i=0
j=0

if [ -z "$1" ]
then
echo "Usage: $0 <module-name>"
exit 1
fi

case $1 in
-h|--help)
echo "Usage: $0 <module-name>"
echo "Run all parallel tests for a single module in node's standard library"
exit 0
;;
esac

export BUN_DEBUG_QUIET_LOGS=1

for x in $(find test/js/node/test/parallel -type f -name "test-$1*.js")
do
i=$((i+1))
echo ./$x
if timeout 2 $PWD/build/debug/bun-debug ./$x
then
j=$((j+1))
git add ./$x
fi
echo
done

echo $i tests tested
echo $j tests passed
8 changes: 3 additions & 5 deletions scripts/check-node.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# How to use this script:
# 1. Pick a module from node's standard library (e.g. 'assert', 'fs')
Expand All @@ -9,7 +9,7 @@
i=0
j=0

if [[ -z $1 ]]
if [ -z "$1" ]
then
echo "Usage: $0 <module-name>"
exit 1
Expand All @@ -18,13 +18,12 @@ fi
case $1 in
-h|--help)
echo "Usage: $0 <module-name>"
echo "Run all parallel tests for a single module in node's standard library"
echo "Run all unstaged parallel tests for a single module in node's standard library"
exit 0
;;
esac

export BUN_DEBUG_QUIET_LOGS=1
export NO_COLOR=1

for x in $(git ls-files test/js/node/test/parallel --exclude-standard --others | grep test-$1)
do
Expand All @@ -36,7 +35,6 @@ do
git add ./$x
fi
echo
echo
done

echo $i tests tested
Expand Down
3 changes: 2 additions & 1 deletion src/bake/BakeProduction.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "BakeProduction.h"
#include "BunBuiltinNames.h"
#include "JavaScriptCore/CallData.h"
#include "WebCoreJSBuiltins.h"
#include "JavaScriptCore/JSPromise.h"
#include "JavaScriptCore/Exception.h"
Expand Down Expand Up @@ -38,7 +39,7 @@ extern "C" JSC::JSPromise* BakeRenderRoutesForProdStatic(
args.append(styles);

NakedPtr<JSC::Exception> returnedException = nullptr;
auto result = JSC::call(global, cb, callData, JSC::jsUndefined(), args, returnedException);
auto result = JSC::profiledCall(global, JSC::ProfilingReason::API, cb, callData, JSC::jsUndefined(), args, returnedException);
if (UNLIKELY(returnedException)) {
// This should be impossible because it returns a promise.
return JSC::JSPromise::rejectedPromise(global, returnedException->value());
Expand Down
7 changes: 4 additions & 3 deletions src/bake/BakeSourceProvider.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// clang-format off
#include "BakeSourceProvider.h"
#include "BakeGlobalObject.h"
#include "JavaScriptCore/CallData.h"
#include "JavaScriptCore/Completion.h"
#include "JavaScriptCore/Identifier.h"
#include "JavaScriptCore/JSCJSValue.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ extern "C" JSC::EncodedJSValue BakeLoadInitialServerCode(GlobalObject* global, B
args.append(JSC::jsBoolean(separateSSRGraph)); // separateSSRGraph
args.append(Zig::ImportMetaObject::create(global, "bake://server-runtime.js"_s)); // importMeta

return JSC::JSValue::encode(JSC::call(global, fn, callData, JSC::jsUndefined(), args));
return JSC::JSValue::encode(JSC::profiledCall(global, JSC::ProfilingReason::API, fn, callData, JSC::jsUndefined(), args));
}

extern "C" JSC::JSInternalPromise* BakeLoadModuleByKey(GlobalObject* global, JSC::JSString* key) {
Expand All @@ -61,7 +62,7 @@ extern "C" JSC::EncodedJSValue BakeLoadServerHmrPatch(GlobalObject* global, BunS
WTF::TextPosition(),
JSC::SourceProviderSourceType::Program
));

JSC::JSValue result = vm.interpreter.executeProgram(sourceCode, global, global);
RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode({}));

Expand Down Expand Up @@ -124,7 +125,7 @@ extern "C" JSC::EncodedJSValue BakeRegisterProductionChunk(JSC::JSGlobalObject*
WTF::TextPosition(),
JSC::SourceProviderSourceType::Module
));

global->moduleLoader()->provideFetch(global, key, sourceCode);
RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode({}));

Expand Down
Loading

0 comments on commit 4bcc5b2

Please sign in to comment.