Skip to content

Commit d1bd779

Browse files
cjihrigtargos
authored andcommitted
test_runner: don't use a symbol for runHook()
This is not exposed to userland, so there is no need to put it behind a symbol. PR-URL: #45792 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 8a03684 commit d1bd779

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

‎lib/internal/test_runner/test.js‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ const testNamePatterns = testNamePatternFlag?.length > 0 ?
7575
(re)=>convertStringToRegExp(re,'--test-name-pattern')
7676
) : null;
7777
constkShouldAbort=Symbol('kShouldAbort');
78-
constkRunHook=Symbol('kRunHook');
7978
constkHookNames=ObjectSeal(['before','after','beforeEach','afterEach']);
8079
constkUnwrapErrors=newSafeSet()
8180
.add(kTestCodeFailure).add(kHookFailure)
@@ -476,7 +475,7 @@ class Test extends AsyncResource {
476475
return{ ctx,args: [ctx]};
477476
}
478477

479-
async[kRunHook](hook,args){
478+
asyncrunHook(hook,args){
480479
validateOneOf(hook,'hook name',kHookNames);
481480
try{
482481
awaitArrayPrototypeReduce(this.hooks[hook],async(prev,hook)=>{
@@ -507,13 +506,13 @@ class Test extends AsyncResource {
507506
const{ args, ctx }=this.getRunArgs();
508507
constafterEach=runOnce(async()=>{
509508
if(this.parent?.hooks.afterEach.length>0){
510-
awaitthis.parent[kRunHook]('afterEach',{ args, ctx });
509+
awaitthis.parent.runHook('afterEach',{ args, ctx });
511510
}
512511
});
513512

514513
try{
515514
if(this.parent?.hooks.beforeEach.length>0){
516-
awaitthis.parent[kRunHook]('beforeEach',{ args, ctx });
515+
awaitthis.parent.runHook('beforeEach',{ args, ctx });
517516
}
518517
conststopPromise=stopTest(this.timeout,this.signal);
519518
construnArgs=ArrayPrototypeSlice(args);
@@ -761,9 +760,10 @@ class Suite extends Test {
761760
consthookArgs=this.getRunArgs();
762761
constafterEach=runOnce(async()=>{
763762
if(this.parent?.hooks.afterEach.length>0){
764-
awaitthis.parent[kRunHook]('afterEach',hookArgs);
763+
awaitthis.parent.runHook('afterEach',hookArgs);
765764
}
766765
});
766+
767767
try{
768768
this.parent.activeSubtests++;
769769
awaitthis.buildSuite;
@@ -775,19 +775,18 @@ class Suite extends Test {
775775
return;
776776
}
777777

778-
779778
if(this.parent?.hooks.beforeEach.length>0){
780-
awaitthis.parent[kRunHook]('beforeEach',hookArgs);
779+
awaitthis.parent.runHook('beforeEach',hookArgs);
781780
}
782781

783-
awaitthis[kRunHook]('before',hookArgs);
782+
awaitthis.runHook('before',hookArgs);
784783

785784
conststopPromise=stopTest(this.timeout,this.signal);
786785
constsubtests=this.skipped||this.error ? [] : this.subtests;
787786
constpromise=SafePromiseAll(subtests,(subtests)=>subtests.start());
788787

789788
awaitSafePromiseRace([promise,stopPromise]);
790-
awaitthis[kRunHook]('after',hookArgs);
789+
awaitthis.runHook('after',hookArgs);
791790
awaitafterEach();
792791

793792
this.pass();

0 commit comments

Comments
 (0)