From dc116ab65a04a11c0c8691a4052c86a4b52eaaf9 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 1 Jul 2024 16:06:59 +0300 Subject: [PATCH] drop compiler.Pool and simplify tc39 --- js/compiler/compiler.go | 33 ---------- ...ing_test_errors-experimental_enhanced.json | 52 ++++++--------- js/tc39/tc39_test.go | 64 +++++++------------ 3 files changed, 44 insertions(+), 105 deletions(-) diff --git a/js/compiler/compiler.go b/js/compiler/compiler.go index 3ee5cd8fedbd..0fbf806f2bfa 100644 --- a/js/compiler/compiler.go +++ b/js/compiler/compiler.go @@ -232,36 +232,3 @@ func (c *compilationState) increaseMappingsByOne(sourceMap []byte) ([]byte, erro return json.Marshal(m) } - -// Pool is a pool of compilers so it can be used easier in parallel tests as they have their own babel. -type Pool struct { - c chan *Compiler -} - -// NewPool creates a Pool that will be using the provided logger and will preallocate (in parallel) -// the count of compilers each with their own babel. -func NewPool(logger logrus.FieldLogger, count int) *Pool { - c := &Pool{ - c: make(chan *Compiler, count), - } - go func() { - for i := 0; i < count; i++ { - go func() { - co := New(logger) - c.Put(co) - }() - } - }() - - return c -} - -// Get a compiler from the pool. -func (c *Pool) Get() *Compiler { - return <-c.c -} - -// Put a compiler back in the pool. -func (c *Pool) Put(co *Compiler) { - c.c <- co -} diff --git a/js/tc39/breaking_test_errors-experimental_enhanced.json b/js/tc39/breaking_test_errors-experimental_enhanced.json index 80c0c043558e..ccc414eb1bc6 100644 --- a/js/tc39/breaking_test_errors-experimental_enhanced.json +++ b/js/tc39/breaking_test_errors-experimental_enhanced.json @@ -34,37 +34,31 @@ "test/language/destructuring/binding/syntax/destructuring-array-parameters-function-arguments-length.js-strict:true": "test/language/destructuring/binding/syntax/destructuring-array-parameters-function-arguments-length.js: SyntaxError: Async generators are not supported yet ", "test/language/destructuring/binding/syntax/destructuring-object-parameters-function-arguments-length.js-strict:true": "test/language/destructuring/binding/syntax/destructuring-object-parameters-function-arguments-length.js: SyntaxError: Async generators are not supported yet ", "test/language/expressions/assignment/fn-name-lhs-cover.js-strict:true": "test/language/expressions/assignment/fn-name-lhs-cover.js: Test262Error: descriptor value should be ", - "test/language/expressions/assignmenttargettype/simple-basic-identifierreference-await.js-strict:true": "test/language/expressions/assignmenttargettype/simple-basic-identifierreference-await.js: test/language/expressions/assignmenttargettype/simple-basic-identifierreference-await.js: Line 9:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/await/await-BindingIdentifier-in-global.js-strict:true": "test/language/expressions/await/await-BindingIdentifier-in-global.js: test/language/expressions/await/await-BindingIdentifier-in-global.js: Line 12:16 Unexpected token await (and 2 more errors)", - "test/language/expressions/await/await-in-global.js-strict:true": "test/language/expressions/await/await-in-global.js: test/language/expressions/await/await-in-global.js: Line 12:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/await/await-in-nested-function.js-strict:true": "test/language/expressions/await/await-in-nested-function.js: test/language/expressions/await/await-in-nested-function.js: Line 12:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/await/await-in-nested-generator.js-strict:true": "test/language/expressions/await/await-in-nested-generator.js: test/language/expressions/await/await-in-nested-generator.js: Line 13:5 Unexpected token await (and 1 more errors)", + "test/language/expressions/assignmenttargettype/simple-basic-identifierreference-await.js-strict:true": "test/language/expressions/assignmenttargettype/simple-basic-identifierreference-await.js: test/language/expressions/assignmenttargettype/simple-basic-identifierreference-await.js: Line 9:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/await/await-BindingIdentifier-in-global.js-strict:true": "test/language/expressions/await/await-BindingIdentifier-in-global.js: test/language/expressions/await/await-BindingIdentifier-in-global.js: Line 12:15 An async function cannot be named \"await\"", + "test/language/expressions/await/await-in-global.js-strict:true": "test/language/expressions/await/await-in-global.js: test/language/expressions/await/await-in-global.js: Line 12:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/await/await-in-nested-function.js-strict:true": "test/language/expressions/await/await-in-nested-function.js: test/language/expressions/await/await-in-nested-function.js: Line 12:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/await/await-in-nested-generator.js-strict:true": "test/language/expressions/await/await-in-nested-generator.js: test/language/expressions/await/await-in-nested-generator.js: Line 13:4 Cannot use \"await\" as an identifier here:", "test/language/expressions/class/class-name-ident-await-escaped-module.js-strict:true": "test/language/expressions/class/class-name-ident-await-escaped-module.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/expressions/class/class-name-ident-await-escaped.js-strict:true": "test/language/expressions/class/class-name-ident-await-escaped.js: test/language/expressions/class/class-name-ident-await-escaped.js: Line 18:15 Keyword must not contain escaped characters (and 3 more errors)", + "test/language/expressions/class/class-name-ident-await-escaped.js-strict:true": "test/language/expressions/class/class-name-ident-await-escaped.js: test/language/expressions/class/class-name-ident-await-escaped.js: Line 18:14 Cannot use \"await\" as an identifier here:", "test/language/expressions/class/class-name-ident-await-module.js-strict:true": "test/language/expressions/class/class-name-ident-await-module.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/expressions/class/class-name-ident-await.js-strict:true": "test/language/expressions/class/class-name-ident-await.js: test/language/expressions/class/class-name-ident-await.js: Line 17:15 Unexpected token await (and 3 more errors)", - "test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-integer-separators.js: test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-integer-separators.js: Line 40:8 Unexpected token ILLEGAL (and 17 more errors)", - "test/language/expressions/class/cpn-class-expr-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-computed-property-name-from-integer-separators.js: test/language/expressions/class/cpn-class-expr-computed-property-name-from-integer-separators.js: Line 40:4 Unexpected token ILLEGAL (and 7 more errors)", - "test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-integer-separators.js: test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-integer-separators.js: Line 40:4 Unexpected token ILLEGAL (and 4 more errors)", - "test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-integer-separators.js: test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-integer-separators.js: Line 40:4 Unexpected token ILLEGAL (and 7 more errors)", + "test/language/expressions/class/class-name-ident-await.js-strict:true": "test/language/expressions/class/class-name-ident-await.js: test/language/expressions/class/class-name-ident-await.js: Line 17:14 Cannot use \"await\" as an identifier here:", "test/language/expressions/class/elements/private-getter-is-not-a-own-property.js-strict:true": "test/language/expressions/class/elements/private-getter-is-not-a-own-property.js: TypeError: Object has no member '__lookupGetter__' ", "test/language/expressions/class/elements/private-setter-is-not-a-own-property.js-strict:true": "test/language/expressions/class/elements/private-setter-is-not-a-own-property.js: TypeError: Object has no member '__lookupSetter__' ", - "test/language/expressions/class/static-init-await-reference.js-strict:true": "test/language/expressions/class/static-init-await-reference.js: test/language/expressions/class/static-init-await-reference.js: Line 15:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/function/static-init-await-reference.js-strict:true": "test/language/expressions/function/static-init-await-reference.js: test/language/expressions/function/static-init-await-reference.js: Line 15:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/generators/static-init-await-reference.js-strict:true": "test/language/expressions/generators/static-init-await-reference.js: test/language/expressions/generators/static-init-await-reference.js: Line 15:5 Unexpected token await (and 1 more errors)", + "test/language/expressions/class/static-init-await-reference.js-strict:true": "test/language/expressions/class/static-init-await-reference.js: test/language/expressions/class/static-init-await-reference.js: Line 15:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/function/static-init-await-reference.js-strict:true": "test/language/expressions/function/static-init-await-reference.js: test/language/expressions/function/static-init-await-reference.js: Line 15:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/generators/static-init-await-reference.js-strict:true": "test/language/expressions/generators/static-init-await-reference.js: test/language/expressions/generators/static-init-await-reference.js: Line 15:4 Cannot use \"await\" as an identifier here:", "test/language/expressions/import.meta/import-meta-is-an-ordinary-object.js-strict:true": "panic while running test/language/expressions/import.meta/import-meta-is-an-ordinary-object.js: interface conversion: *sobek.Program is not sobek.ModuleRecord: missing method Evaluate", "test/language/expressions/import.meta/same-object-returned.js-strict:true": "panic while running test/language/expressions/import.meta/same-object-returned.js: interface conversion: *sobek.Program is not sobek.ModuleRecord: missing method Evaluate", "test/language/expressions/import.meta/syntax/goal-script.js-strict:true": "test/language/expressions/import.meta/syntax/goal-script.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/expressions/in/private-field-rhs-await-absent.js-strict:true": "test/language/expressions/in/private-field-rhs-await-absent.js: test/language/expressions/in/private-field-rhs-await-absent.js: Line 24:10 Unexpected token await", - "test/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js: test/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js: Line 29:4 Unexpected token ILLEGAL (and 6 more errors)", - "test/language/expressions/object/identifier-shorthand-await-strict-mode.js-strict:false": "test/language/expressions/object/identifier-shorthand-await-strict-mode.js: test/language/expressions/object/identifier-shorthand-await-strict-mode.js: Line 19:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/object/method-definition/static-init-await-reference-accessor.js-strict:true": "test/language/expressions/object/method-definition/static-init-await-reference-accessor.js: test/language/expressions/object/method-definition/static-init-await-reference-accessor.js: Line 15:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/object/method-definition/static-init-await-reference-generator.js-strict:true": "test/language/expressions/object/method-definition/static-init-await-reference-generator.js: test/language/expressions/object/method-definition/static-init-await-reference-generator.js: Line 15:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/object/method-definition/static-init-await-reference-normal.js-strict:true": "test/language/expressions/object/method-definition/static-init-await-reference-normal.js: test/language/expressions/object/method-definition/static-init-await-reference-normal.js: Line 15:5 Unexpected token await (and 1 more errors)", - "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js-strict:true": "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: Line 31:7 Unexpected token await (and 9 more errors)", + "test/language/expressions/in/private-field-rhs-await-absent.js-strict:true": "test/language/expressions/in/private-field-rhs-await-absent.js: test/language/expressions/in/private-field-rhs-await-absent.js: Line 24:9 Cannot use \"await\" as an identifier here:", + "test/language/expressions/object/identifier-shorthand-await-strict-mode.js-strict:false": "test/language/expressions/object/identifier-shorthand-await-strict-mode.js: test/language/expressions/object/identifier-shorthand-await-strict-mode.js: Line 19:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/object/method-definition/static-init-await-reference-accessor.js-strict:true": "test/language/expressions/object/method-definition/static-init-await-reference-accessor.js: test/language/expressions/object/method-definition/static-init-await-reference-accessor.js: Line 15:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/object/method-definition/static-init-await-reference-generator.js-strict:true": "test/language/expressions/object/method-definition/static-init-await-reference-generator.js: test/language/expressions/object/method-definition/static-init-await-reference-generator.js: Line 15:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/object/method-definition/static-init-await-reference-normal.js-strict:true": "test/language/expressions/object/method-definition/static-init-await-reference-normal.js: test/language/expressions/object/method-definition/static-init-await-reference-normal.js: Line 15:4 Cannot use \"await\" as an identifier here:", + "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js-strict:true": "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: Line 19:7 Unexpected token await (and 9 more errors)", "test/language/expressions/optional-chaining/member-expression.js-strict:true": "test/language/expressions/optional-chaining/member-expression.js: SyntaxError: Async generators are not supported yet ", "test/language/global-code/import.js-strict:true": "test/language/global-code/import.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/literals/numeric/non-octal-decimal-integer.js-strict:false": "test/language/literals/numeric/non-octal-decimal-integer.js: test/language/literals/numeric/non-octal-decimal-integer.js: Line 28:18 Unexpected token ILLEGAL (and 1 more errors)", "test/language/literals/regexp/S7.8.5_A1.1_T2.js-strict:true": "test/language/literals/regexp/S7.8.5_A1.1_T2.js: Test262Error: Code unit: d800 Expected SameValue(«\\ud800», «�») to be true ", "test/language/literals/regexp/S7.8.5_A1.4_T2.js-strict:true": "test/language/literals/regexp/S7.8.5_A1.4_T2.js: Test262Error: Code unit: d800 Expected SameValue(«\\\\\\ud800», «\\�») to be true ", "test/language/literals/regexp/S7.8.5_A2.1_T2.js-strict:true": "test/language/literals/regexp/S7.8.5_A2.1_T2.js: Test262Error: Code unit: d800 Expected SameValue(«nnnn\\ud800», «nnnn�») to be true ", @@ -107,19 +101,15 @@ "test/language/module-code/parse-err-hoist-lex-fun.js-strict:true": "test/language/module-code/parse-err-hoist-lex-fun.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/module-code/parse-err-return.js-strict:true": "test/language/module-code/parse-err-return.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/reserved-words/await-module.js-strict:true": "test/language/reserved-words/await-module.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/reserved-words/await-script.js-strict:true": "test/language/reserved-words/await-script.js: test/language/reserved-words/await-script.js: Line 10:5 Unexpected token await (and 1 more errors)", + "test/language/reserved-words/await-script.js-strict:true": "test/language/reserved-words/await-script.js: test/language/reserved-words/await-script.js: Line 10:4 Cannot use \"await\" as an identifier here:", "test/language/statements/class/class-name-ident-await-escaped-module.js-strict:true": "test/language/statements/class/class-name-ident-await-escaped-module.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/statements/class/class-name-ident-await-escaped.js-strict:true": "test/language/statements/class/class-name-ident-await-escaped.js: test/language/statements/class/class-name-ident-await-escaped.js: Line 18:7 Keyword must not contain escaped characters", + "test/language/statements/class/class-name-ident-await-escaped.js-strict:true": "test/language/statements/class/class-name-ident-await-escaped.js: test/language/statements/class/class-name-ident-await-escaped.js: Line 18:6 Cannot use \"await\" as an identifier here:", "test/language/statements/class/class-name-ident-await-module.js-strict:true": "test/language/statements/class/class-name-ident-await-module.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/statements/class/class-name-ident-await.js-strict:true": "test/language/statements/class/class-name-ident-await.js: test/language/statements/class/class-name-ident-await.js: Line 17:7 Unexpected token await", - "test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js: test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js: Line 40:8 Unexpected token ILLEGAL (and 16 more errors)", - "test/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js: test/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js: Line 40:4 Unexpected token ILLEGAL (and 6 more errors)", - "test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js: test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js: Line 40:4 Unexpected token ILLEGAL (and 4 more errors)", - "test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js: test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js: Line 40:4 Unexpected token ILLEGAL (and 7 more errors)", + "test/language/statements/class/class-name-ident-await.js-strict:true": "test/language/statements/class/class-name-ident-await.js: test/language/statements/class/class-name-ident-await.js: Line 17:6 Cannot use \"await\" as an identifier here:", "test/language/statements/class/elements/private-getter-is-not-a-own-property.js-strict:true": "test/language/statements/class/elements/private-getter-is-not-a-own-property.js: TypeError: Object has no member '__lookupGetter__' ", "test/language/statements/class/elements/private-setter-is-not-a-own-property.js-strict:true": "test/language/statements/class/elements/private-setter-is-not-a-own-property.js: TypeError: Object has no member '__lookupSetter__' ", "test/language/statements/labeled/value-await-module-escaped.js-strict:true": "test/language/statements/labeled/value-await-module-escaped.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/statements/labeled/value-await-module.js-strict:true": "test/language/statements/labeled/value-await-module.js: error is not an object (Test262: This statement should not be evaluated.)", - "test/language/statements/labeled/value-await-non-module-escaped.js-strict:true": "test/language/statements/labeled/value-await-non-module-escaped.js: test/language/statements/labeled/value-await-non-module-escaped.js: Line 16:1 Keyword must not contain escaped characters", - "test/language/statements/labeled/value-await-non-module.js-strict:true": "test/language/statements/labeled/value-await-non-module.js: test/language/statements/labeled/value-await-non-module.js: Line 15:6 Unexpected token :" + "test/language/statements/labeled/value-await-non-module-escaped.js-strict:true": "test/language/statements/labeled/value-await-non-module-escaped.js: test/language/statements/labeled/value-await-non-module-escaped.js: Line 16:0 The keyword \"await\" cannot be escaped", + "test/language/statements/labeled/value-await-non-module.js-strict:true": "test/language/statements/labeled/value-await-non-module.js: test/language/statements/labeled/value-await-non-module.js: Line 15:5 Unexpected \":\"" } diff --git a/js/tc39/tc39_test.go b/js/tc39/tc39_test.go index b9911394e99b..358700ec9b57 100644 --- a/js/tc39/tc39_test.go +++ b/js/tc39/tc39_test.go @@ -15,7 +15,6 @@ import ( "os" "path" "path/filepath" - "runtime" "sort" "strings" "sync" @@ -247,7 +246,6 @@ type tc39BenchmarkItem struct { type tc39BenchmarkData []tc39BenchmarkItem type tc39TestCtx struct { - compilerPool *compiler.Pool base string t *testing.T prgCache map[string]*sobek.Program @@ -409,11 +407,10 @@ func (ctx *tc39TestCtx) runTC39Test(t testing.TB, name, src string, meta *tc39Me _ = vm.Set("print", t.Log) } var early bool - var origErr error if meta.hasFlag("module") { - early, origErr, err = ctx.runTC39Module(name, src, meta.Includes, vm) + early, err = ctx.runTC39Module(name, src, meta.Includes, vm) } else { - early, origErr, err = ctx.runTC39Script(name, src, meta.Includes, vm, meta.Negative.Type != "") + early, err = ctx.runTC39Script(name, src, meta.Includes, vm, meta.Negative.Type != "") } if err == nil { @@ -444,9 +441,6 @@ func (ctx *tc39TestCtx) runTC39Test(t testing.TB, name, src string, meta *tc39Me errType := getErrType(name, err, failf) if errType != "" && errType != meta.Negative.Type { - if meta.Negative.Type == "SyntaxError" && origErr != nil && getErrType(name, origErr, failf) == meta.Negative.Type { - return - } // vm.vm.prg.dumpCode(t.Logf) failf("%s: unexpected error type (%s), expected (%s)", name, errType, meta.Negative.Type) return @@ -604,11 +598,7 @@ func (ctx *tc39TestCtx) compile(base, name string) (*sobek.Program, error) { return nil, err } - str := string(b) - comp := ctx.compilerPool.Get() - defer ctx.compilerPool.Put(comp) - comp.Options = compiler.Options{Strict: false, CompatibilityMode: ctx.compatibilityMode} - prg, _, err = comp.Compile(str, name, true) + prg, _, err = ctx.compiler().Compile(string(b), name, true) if err != nil { return nil, err } @@ -627,77 +617,70 @@ func (ctx *tc39TestCtx) runFile(base, name string, vm *sobek.Runtime) error { return err } -func (ctx *tc39TestCtx) runTC39Script(name, src string, includes []string, vm *sobek.Runtime, _ bool) (early bool, origErr, err error) { +func (ctx *tc39TestCtx) compiler() *compiler.Compiler { + comp := compiler.New(testutils.NewLogger(ctx.t)) + comp.Options.CompatibilityMode = ctx.compatibilityMode + return comp +} + +func (ctx *tc39TestCtx) runTC39Script(name, src string, includes []string, vm *sobek.Runtime, _ bool) (early bool, err error) { early = true err = ctx.runFile(ctx.base, path.Join("harness", "assert.js"), vm) if err != nil { - return early, origErr, err + return early, err } err = ctx.runFile(ctx.base, path.Join("harness", "sta.js"), vm) if err != nil { - return early, origErr, err + return early, err } for _, include := range includes { err = ctx.runFile(ctx.base, path.Join("harness", include), vm) if err != nil { - return early, origErr, err + return early, err } } - var p *sobek.Program - comp := ctx.compilerPool.Get() - defer ctx.compilerPool.Put(comp) - comp.Options = compiler.Options{Strict: false, CompatibilityMode: lib.CompatibilityModeBase} - p, _, err = comp.Compile(src, name, true) - origErr = err + p, _, err := ctx.compiler().Compile(src, name, true) if err != nil { - return early, origErr, err + return early, err } early = false _, err = vm.RunProgram(p) - return early, origErr, err + return early, err } -func (ctx *tc39TestCtx) runTC39Module(name, src string, includes []string, vm *sobek.Runtime) (early bool, origErr, err error) { - currentFS := os.DirFS(".") - if err != nil { - panic(err) - } +func (ctx *tc39TestCtx) runTC39Module(name, src string, includes []string, vm *sobek.Runtime) (early bool, err error) { moduleRuntime := modulestest.NewRuntime(ctx.t) moduleRuntime.VU.RuntimeField = vm early = true err = ctx.runFile(ctx.base, path.Join("harness", "assert.js"), vm) if err != nil { - return early, origErr, err + return early, err } err = ctx.runFile(ctx.base, path.Join("harness", "sta.js"), vm) if err != nil { - return early, origErr, err + return early, err } for _, include := range includes { err = ctx.runFile(ctx.base, path.Join("harness", include), vm) if err != nil { - return early, origErr, err + return early, err } } - comp := ctx.compilerPool.Get() - defer ctx.compilerPool.Put(comp) - comp.Options = compiler.Options{Strict: false, CompatibilityMode: ctx.compatibilityMode} - u := &url.URL{Scheme: "file", Path: "/" + path.Join(ctx.base, name)} base := u.JoinPath("..") mr := modules.NewModuleResolver(nil, func(specifier *url.URL, _ string) ([]byte, error) { - return fs.ReadFile(currentFS, specifier.Path[1:]) + return fs.ReadFile(os.DirFS("."), specifier.Path[1:]) }, - comp, base) + ctx.compiler(), base) ms := modules.NewModuleSystem(mr, moduleRuntime.VU) moduleRuntime.VU.InitEnvField.CWD = base @@ -708,7 +691,7 @@ func (ctx *tc39TestCtx) runTC39Module(name, src string, includes []string, vm *s URL: u, }) - return early, origErr, err + return early, err } func (ctx *tc39TestCtx) runTC39Tests(name string) { @@ -768,7 +751,6 @@ func runTestTC39(t *testing.T, compatibilityMode lib.CompatibilityMode) { ctx := &tc39TestCtx{ base: tc39BASE, - compilerPool: compiler.NewPool(testutils.NewLogger(t), runtime.GOMAXPROCS(0)), compatibilityMode: compatibilityMode, } ctx.init()