goscript 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cmd/goscript/cmd-test.go +104 -11
- package/cmd/goscript/cmd-test_test.go +1 -1
- package/cmd/goscript/cmd_compile.go +9 -0
- package/compiler/compile-request.go +31 -0
- package/compiler/compiler.go +1 -1
- package/compiler/compliance_test.go +0 -2
- package/compiler/config.go +2 -0
- package/compiler/gotest/package-result.go +2 -0
- package/compiler/gotest/request.go +85 -20
- package/compiler/gotest/runner.go +733 -96
- package/compiler/gotest/runner_test.go +647 -3
- package/compiler/lowered-program.go +9 -2
- package/compiler/lowering.go +2001 -345
- package/compiler/override-facts.go +77 -27
- package/compiler/override-registry.go +5 -4
- package/compiler/override-registry_test.go +135 -0
- package/compiler/package-graph_test.go +62 -7
- package/compiler/package-test-graph-variant.go +40 -16
- package/compiler/package-test-graph.go +0 -5
- package/compiler/package-test-graph_test.go +61 -3
- package/compiler/runtime-contract.go +40 -0
- package/compiler/semantic-model-types.go +16 -0
- package/compiler/semantic-model.go +336 -91
- package/compiler/semantic-model_test.go +50 -1
- package/compiler/service.go +9 -3
- package/compiler/skeleton_test.go +1921 -298
- package/compiler/tsworkspace/owner-process-unix_test.go +72 -0
- package/compiler/tsworkspace/owner.go +8 -0
- package/compiler/tsworkspace/tool-process-other.go +14 -0
- package/compiler/tsworkspace/tool-process-unix.go +19 -0
- package/compiler/typescript-emitter.go +122 -9
- package/dist/gs/builtin/builtin.d.ts +20 -1
- package/dist/gs/builtin/builtin.js +246 -26
- package/dist/gs/builtin/builtin.js.map +1 -1
- package/dist/gs/builtin/channel.d.ts +24 -10
- package/dist/gs/builtin/channel.js +107 -25
- package/dist/gs/builtin/channel.js.map +1 -1
- package/dist/gs/builtin/defer.d.ts +1 -0
- package/dist/gs/builtin/defer.js +12 -2
- package/dist/gs/builtin/defer.js.map +1 -1
- package/dist/gs/builtin/hostio.d.ts +9 -0
- package/dist/gs/builtin/hostio.js +25 -0
- package/dist/gs/builtin/hostio.js.map +1 -1
- package/dist/gs/builtin/map.js +40 -6
- package/dist/gs/builtin/map.js.map +1 -1
- package/dist/gs/builtin/print.js.map +1 -1
- package/dist/gs/builtin/slice.d.ts +43 -9
- package/dist/gs/builtin/slice.js +437 -234
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/builtin/type.d.ts +2 -0
- package/dist/gs/builtin/type.js +47 -7
- package/dist/gs/builtin/type.js.map +1 -1
- package/dist/gs/builtin/varRef.d.ts +2 -0
- package/dist/gs/builtin/varRef.js.map +1 -1
- package/dist/gs/bytes/buffer.gs.js +28 -28
- package/dist/gs/bytes/buffer.gs.js.map +1 -1
- package/dist/gs/bytes/iter.gs.js +13 -13
- package/dist/gs/bytes/iter.gs.js.map +1 -1
- package/dist/gs/compress/zlib/index.d.ts +26 -0
- package/dist/gs/compress/zlib/index.js +168 -0
- package/dist/gs/compress/zlib/index.js.map +1 -0
- package/dist/gs/context/context.d.ts +1 -1
- package/dist/gs/context/context.js +8 -3
- package/dist/gs/context/context.js.map +1 -1
- package/dist/gs/crypto/ecdh/index.d.ts +52 -0
- package/dist/gs/crypto/ecdh/index.js +226 -0
- package/dist/gs/crypto/ecdh/index.js.map +1 -0
- package/dist/gs/crypto/ed25519/index.d.ts +34 -0
- package/dist/gs/crypto/ed25519/index.js +160 -0
- package/dist/gs/crypto/ed25519/index.js.map +1 -0
- package/dist/gs/crypto/internal/constanttime/index.d.ts +4 -0
- package/dist/gs/crypto/internal/constanttime/index.js +18 -0
- package/dist/gs/crypto/internal/constanttime/index.js.map +1 -0
- package/dist/gs/crypto/rand/index.d.ts +2 -0
- package/dist/gs/crypto/rand/index.js +85 -0
- package/dist/gs/crypto/rand/index.js.map +1 -1
- package/dist/gs/crypto/sha256/index.d.ts +8 -0
- package/dist/gs/crypto/sha256/index.js +118 -0
- package/dist/gs/crypto/sha256/index.js.map +1 -0
- package/dist/gs/crypto/sha512/index.d.ts +14 -0
- package/dist/gs/crypto/sha512/index.js +129 -0
- package/dist/gs/crypto/sha512/index.js.map +1 -0
- package/dist/gs/encoding/json/index.d.ts +3 -0
- package/dist/gs/encoding/json/index.js +15 -0
- package/dist/gs/encoding/json/index.js.map +1 -1
- package/dist/gs/errors/errors.js +29 -6
- package/dist/gs/errors/errors.js.map +1 -1
- package/dist/gs/fmt/fmt.js.map +1 -1
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.d.ts +7 -7
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.js +52 -18
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.js.map +1 -1
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/json/index.js +56 -20
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/json/index.js.map +1 -1
- package/dist/gs/github.com/aperturerobotics/starpc/srpc/index.d.ts +57 -3
- package/dist/gs/github.com/aperturerobotics/starpc/srpc/index.js +366 -1
- package/dist/gs/github.com/aperturerobotics/starpc/srpc/index.js.map +1 -1
- package/dist/gs/github.com/aperturerobotics/util/conc/index.d.ts +20 -0
- package/dist/gs/github.com/aperturerobotics/util/conc/index.js +134 -0
- package/dist/gs/github.com/aperturerobotics/util/conc/index.js.map +1 -0
- package/dist/gs/github.com/aperturerobotics/wasivm/wazero/kernel/runtime/browser/browser.js.map +1 -1
- package/dist/gs/github.com/hack-pad/safejs/internal/catch/index.d.ts +3 -0
- package/dist/gs/github.com/hack-pad/safejs/internal/catch/index.js +50 -0
- package/dist/gs/github.com/hack-pad/safejs/internal/catch/index.js.map +1 -0
- package/dist/gs/github.com/klauspost/compress/internal/le/index.js +3 -2
- package/dist/gs/github.com/klauspost/compress/internal/le/index.js.map +1 -1
- package/dist/gs/github.com/mr-tron/base58/base58/index.d.ts +27 -0
- package/dist/gs/github.com/mr-tron/base58/base58/index.js +172 -0
- package/dist/gs/github.com/mr-tron/base58/base58/index.js.map +1 -0
- package/dist/gs/github.com/zeebo/blake3/internal/consts/index.d.ts +21 -0
- package/dist/gs/github.com/zeebo/blake3/internal/consts/index.js +22 -0
- package/dist/gs/github.com/zeebo/blake3/internal/consts/index.js.map +1 -0
- package/dist/gs/go/token/index.js +11 -4
- package/dist/gs/go/token/index.js.map +1 -1
- package/dist/gs/hash/fnv/index.d.ts +57 -0
- package/dist/gs/hash/fnv/index.js +299 -0
- package/dist/gs/hash/fnv/index.js.map +1 -0
- package/dist/gs/hash/index.d.ts +17 -0
- package/dist/gs/hash/index.js +94 -0
- package/dist/gs/hash/index.js.map +1 -0
- package/dist/gs/io/fs/readlink.js +2 -6
- package/dist/gs/io/fs/readlink.js.map +1 -1
- package/dist/gs/io/fs/walk.js.map +1 -1
- package/dist/gs/io/io.js.map +1 -1
- package/dist/gs/iter/iter.d.ts +3 -2
- package/dist/gs/iter/iter.js.map +1 -1
- package/dist/gs/maps/iter.d.ts +5 -5
- package/dist/gs/maps/iter.js +48 -21
- package/dist/gs/maps/iter.js.map +1 -1
- package/dist/gs/maps/maps.d.ts +6 -6
- package/dist/gs/math/bits/index.js +14 -24
- package/dist/gs/math/bits/index.js.map +1 -1
- package/dist/gs/mime/index.js +3 -1
- package/dist/gs/mime/index.js.map +1 -1
- package/dist/gs/net/http/httptest/index.d.ts +20 -1
- package/dist/gs/net/http/httptest/index.js +83 -3
- package/dist/gs/net/http/httptest/index.js.map +1 -1
- package/dist/gs/net/http/index.d.ts +110 -6
- package/dist/gs/net/http/index.js +262 -16
- package/dist/gs/net/http/index.js.map +1 -1
- package/dist/gs/net/http/pprof/index.d.ts +8 -0
- package/dist/gs/net/http/pprof/index.js +59 -0
- package/dist/gs/net/http/pprof/index.js.map +1 -0
- package/dist/gs/os/error.gs.js +9 -7
- package/dist/gs/os/error.gs.js.map +1 -1
- package/dist/gs/os/types_js.gs.js +95 -15
- package/dist/gs/os/types_js.gs.js.map +1 -1
- package/dist/gs/path/filepath/match.js.map +1 -1
- package/dist/gs/path/filepath/path.d.ts +5 -3
- package/dist/gs/path/filepath/path.js +65 -10
- package/dist/gs/path/filepath/path.js.map +1 -1
- package/dist/gs/reflect/index.d.ts +3 -2
- package/dist/gs/reflect/index.js +2 -1
- package/dist/gs/reflect/index.js.map +1 -1
- package/dist/gs/reflect/iter.js +2 -2
- package/dist/gs/reflect/iter.js.map +1 -1
- package/dist/gs/reflect/map.js +26 -0
- package/dist/gs/reflect/map.js.map +1 -1
- package/dist/gs/reflect/type.d.ts +24 -5
- package/dist/gs/reflect/type.js +390 -38
- package/dist/gs/reflect/type.js.map +1 -1
- package/dist/gs/reflect/types.d.ts +1 -0
- package/dist/gs/reflect/types.js +3 -1
- package/dist/gs/reflect/types.js.map +1 -1
- package/dist/gs/reflect/value.d.ts +4 -1
- package/dist/gs/reflect/value.js +39 -1
- package/dist/gs/reflect/value.js.map +1 -1
- package/dist/gs/reflect/visiblefields.js +1 -1
- package/dist/gs/reflect/visiblefields.js.map +1 -1
- package/dist/gs/runtime/debug/index.d.ts +39 -0
- package/dist/gs/runtime/debug/index.js +58 -0
- package/dist/gs/runtime/debug/index.js.map +1 -1
- package/dist/gs/runtime/pprof/index.d.ts +20 -0
- package/dist/gs/runtime/pprof/index.js +85 -0
- package/dist/gs/runtime/pprof/index.js.map +1 -0
- package/dist/gs/runtime/trace/index.d.ts +19 -0
- package/dist/gs/runtime/trace/index.js +64 -0
- package/dist/gs/runtime/trace/index.js.map +1 -0
- package/dist/gs/slices/slices.d.ts +24 -9
- package/dist/gs/slices/slices.js +229 -24
- package/dist/gs/slices/slices.js.map +1 -1
- package/dist/gs/sort/slice.gs.d.ts +5 -3
- package/dist/gs/sort/slice.gs.js +55 -17
- package/dist/gs/sort/slice.gs.js.map +1 -1
- package/dist/gs/strings/builder.js +26 -17
- package/dist/gs/strings/builder.js.map +1 -1
- package/dist/gs/strings/iter.js +140 -75
- package/dist/gs/strings/iter.js.map +1 -1
- package/dist/gs/strings/replace.js +2 -2
- package/dist/gs/strings/replace.js.map +1 -1
- package/dist/gs/strings/strings.js +52 -6
- package/dist/gs/strings/strings.js.map +1 -1
- package/dist/gs/sync/sync.d.ts +6 -3
- package/dist/gs/sync/sync.js +39 -11
- package/dist/gs/sync/sync.js.map +1 -1
- package/dist/gs/syscall/errors.d.ts +116 -112
- package/dist/gs/syscall/errors.js +38 -1
- package/dist/gs/syscall/errors.js.map +1 -1
- package/dist/gs/syscall/fs.d.ts +2 -8
- package/dist/gs/syscall/fs.js.map +1 -1
- package/dist/gs/syscall/js/index.js +20 -12
- package/dist/gs/syscall/js/index.js.map +1 -1
- package/dist/gs/syscall/types.d.ts +4 -1
- package/dist/gs/syscall/types.js.map +1 -1
- package/dist/gs/testing/testing.d.ts +4 -3
- package/dist/gs/testing/testing.js +21 -4
- package/dist/gs/testing/testing.js.map +1 -1
- package/dist/gs/time/time.js +22 -0
- package/dist/gs/time/time.js.map +1 -1
- package/dist/gs/unicode/unicode.js.map +1 -1
- package/dist/gs/unique/index.js +7 -2
- package/dist/gs/unique/index.js.map +1 -1
- package/go.mod +8 -8
- package/go.sum +14 -23
- package/gs/builtin/builtin.ts +364 -37
- package/gs/builtin/channel.ts +161 -29
- package/gs/builtin/defer.ts +13 -2
- package/gs/builtin/hostio.test.ts +1 -0
- package/gs/builtin/hostio.ts +38 -0
- package/gs/builtin/map.ts +46 -6
- package/gs/builtin/print.ts +12 -3
- package/gs/builtin/runtime-contract.test.ts +257 -10
- package/gs/builtin/slice.test.ts +70 -0
- package/gs/builtin/slice.ts +566 -255
- package/gs/builtin/type.ts +53 -9
- package/gs/builtin/varRef.ts +2 -0
- package/gs/bytes/buffer.gs.ts +28 -28
- package/gs/bytes/iter.gs.ts +13 -14
- package/gs/compress/zlib/index.test.ts +28 -0
- package/gs/compress/zlib/index.ts +200 -0
- package/gs/compress/zlib/meta.json +3 -0
- package/gs/context/context.test.ts +31 -1
- package/gs/context/context.ts +9 -4
- package/gs/crypto/ecdh/index.test.ts +43 -0
- package/gs/crypto/ecdh/index.ts +274 -0
- package/gs/crypto/ed25519/index.test.ts +41 -0
- package/gs/crypto/ed25519/index.ts +238 -0
- package/gs/crypto/ed25519/meta.json +13 -0
- package/gs/crypto/internal/constanttime/index.test.ts +25 -0
- package/gs/crypto/internal/constanttime/index.ts +22 -0
- package/gs/crypto/rand/index.test.ts +89 -1
- package/gs/crypto/rand/index.ts +103 -1
- package/gs/crypto/rand/meta.json +4 -1
- package/gs/crypto/sha256/index.test.ts +78 -0
- package/gs/crypto/sha256/index.ts +150 -0
- package/gs/crypto/sha256/meta.json +9 -0
- package/gs/crypto/sha512/index.test.ts +31 -0
- package/gs/crypto/sha512/index.ts +161 -0
- package/gs/crypto/sha512/meta.json +11 -0
- package/gs/encoding/json/index.test.ts +25 -3
- package/gs/encoding/json/index.ts +21 -3
- package/gs/errors/errors.test.ts +4 -1
- package/gs/errors/errors.ts +32 -8
- package/gs/fmt/fmt.test.ts +3 -1
- package/gs/fmt/fmt.ts +1 -5
- package/gs/github.com/aperturerobotics/protobuf-go-lite/index.test.ts +62 -7
- package/gs/github.com/aperturerobotics/protobuf-go-lite/index.ts +78 -36
- package/gs/github.com/aperturerobotics/protobuf-go-lite/json/index.test.ts +32 -11
- package/gs/github.com/aperturerobotics/protobuf-go-lite/json/index.ts +122 -43
- package/gs/github.com/aperturerobotics/starpc/srpc/index.test.ts +31 -0
- package/gs/github.com/aperturerobotics/starpc/srpc/index.ts +518 -4
- package/gs/github.com/aperturerobotics/starpc/srpc/meta.json +6 -0
- package/gs/github.com/aperturerobotics/util/conc/index.test.ts +30 -0
- package/gs/github.com/aperturerobotics/util/conc/index.ts +172 -0
- package/gs/github.com/aperturerobotics/util/conc/meta.json +9 -0
- package/gs/github.com/aperturerobotics/wasivm/wazero/kernel/runtime/browser/browser.ts +1 -4
- package/gs/github.com/hack-pad/safejs/internal/catch/index.test.ts +35 -0
- package/gs/github.com/hack-pad/safejs/internal/catch/index.ts +65 -0
- package/gs/github.com/hack-pad/safejs/internal/catch/meta.json +9 -0
- package/gs/github.com/klauspost/compress/internal/le/index.test.ts +2 -1
- package/gs/github.com/klauspost/compress/internal/le/index.ts +6 -5
- package/gs/github.com/mr-tron/base58/base58/index.test.ts +70 -0
- package/gs/github.com/mr-tron/base58/base58/index.ts +231 -0
- package/gs/github.com/mr-tron/base58/base58/meta.json +3 -0
- package/gs/github.com/zeebo/blake3/internal/consts/index.test.ts +46 -0
- package/gs/github.com/zeebo/blake3/internal/consts/index.ts +26 -0
- package/gs/go/token/index.ts +17 -4
- package/gs/hash/fnv/index.test.ts +67 -0
- package/gs/hash/fnv/index.ts +351 -0
- package/gs/hash/fnv/meta.json +3 -0
- package/gs/hash/index.test.ts +37 -0
- package/gs/hash/index.ts +118 -0
- package/gs/hash/meta.json +5 -0
- package/gs/internal/byteorder/index.test.ts +6 -6
- package/gs/io/fs/readlink.ts +40 -48
- package/gs/io/fs/walk.ts +10 -2
- package/gs/io/io.ts +4 -1
- package/gs/iter/iter.ts +8 -2
- package/gs/maps/iter.ts +69 -26
- package/gs/maps/maps.test.ts +23 -0
- package/gs/maps/maps.ts +6 -6
- package/gs/math/bits/index.test.ts +20 -0
- package/gs/math/bits/index.ts +15 -28
- package/gs/mime/index.ts +8 -2
- package/gs/net/http/httptest/index.test.ts +53 -0
- package/gs/net/http/httptest/index.ts +98 -3
- package/gs/net/http/index.test.ts +129 -1
- package/gs/net/http/index.ts +370 -19
- package/gs/net/http/meta.json +6 -0
- package/gs/net/http/pprof/index.test.ts +47 -0
- package/gs/net/http/pprof/index.ts +65 -0
- package/gs/os/error.gs.ts +9 -10
- package/gs/os/error.test.ts +41 -0
- package/gs/os/file_unix_js.test.ts +55 -0
- package/gs/os/tempfile.gs.test.ts +37 -10
- package/gs/os/types_js.gs.ts +94 -15
- package/gs/path/filepath/match.ts +4 -1
- package/gs/path/filepath/meta.json +6 -0
- package/gs/path/filepath/path.test.ts +57 -2
- package/gs/path/filepath/path.ts +91 -12
- package/gs/reflect/field.test.ts +63 -0
- package/gs/reflect/index.ts +4 -1
- package/gs/reflect/iter.ts +2 -2
- package/gs/reflect/map.test.ts +24 -2
- package/gs/reflect/map.ts +35 -0
- package/gs/reflect/type.ts +543 -60
- package/gs/reflect/typefor.test.ts +100 -0
- package/gs/reflect/types.ts +3 -1
- package/gs/reflect/value.ts +50 -1
- package/gs/reflect/visiblefields.ts +1 -1
- package/gs/runtime/debug/index.test.ts +22 -1
- package/gs/runtime/debug/index.ts +88 -0
- package/gs/runtime/pprof/index.test.ts +36 -0
- package/gs/runtime/pprof/index.ts +104 -0
- package/gs/runtime/pprof/meta.json +6 -0
- package/gs/runtime/trace/index.test.ts +45 -0
- package/gs/runtime/trace/index.ts +97 -0
- package/gs/runtime/trace/meta.json +7 -0
- package/gs/slices/meta.json +2 -1
- package/gs/slices/slices.test.ts +86 -0
- package/gs/slices/slices.ts +284 -37
- package/gs/sort/slice.gs.ts +73 -23
- package/gs/sort/slice.test.ts +40 -0
- package/gs/strings/builder.test.ts +8 -0
- package/gs/strings/builder.ts +29 -17
- package/gs/strings/iter.test.ts +5 -7
- package/gs/strings/iter.ts +146 -71
- package/gs/strings/replace.test.ts +1 -4
- package/gs/strings/replace.ts +6 -6
- package/gs/strings/strings.test.ts +4 -0
- package/gs/strings/strings.ts +54 -6
- package/gs/sync/sync.test.ts +57 -1
- package/gs/sync/sync.ts +45 -13
- package/gs/syscall/errors.ts +158 -115
- package/gs/syscall/fs.ts +8 -8
- package/gs/syscall/js/index.ts +49 -22
- package/gs/syscall/net.test.ts +26 -0
- package/gs/syscall/types.ts +7 -2
- package/gs/testing/testing.test.ts +56 -0
- package/gs/testing/testing.ts +27 -10
- package/gs/time/meta.json +2 -2
- package/gs/time/time.test.ts +4 -0
- package/gs/time/time.ts +33 -2
- package/gs/unicode/unicode.test.ts +14 -3
- package/gs/unicode/unicode.ts +1 -5
- package/gs/unique/index.ts +9 -2
- package/package.json +3 -3
package/cmd/goscript/cmd-test.go
CHANGED
|
@@ -3,6 +3,9 @@ package main
|
|
|
3
3
|
import (
|
|
4
4
|
"context"
|
|
5
5
|
"io"
|
|
6
|
+
"os"
|
|
7
|
+
"runtime"
|
|
8
|
+
"runtime/pprof"
|
|
6
9
|
"strconv"
|
|
7
10
|
"strings"
|
|
8
11
|
"time"
|
|
@@ -18,6 +21,7 @@ func testCommands() []*cli.Command {
|
|
|
18
21
|
|
|
19
22
|
func newTestCommand() *cli.Command {
|
|
20
23
|
var tags cli.StringSlice
|
|
24
|
+
var overrideDirs cli.StringSlice
|
|
21
25
|
var run string
|
|
22
26
|
var count int
|
|
23
27
|
var short bool
|
|
@@ -26,24 +30,45 @@ func newTestCommand() *cli.Command {
|
|
|
26
30
|
var outputRoot string
|
|
27
31
|
var workDir string
|
|
28
32
|
var dir string
|
|
33
|
+
var parallelism int
|
|
34
|
+
var runtimeGroups bool
|
|
35
|
+
var cpuProfile string
|
|
36
|
+
var memProfile string
|
|
37
|
+
var incrementalTypeCheck bool
|
|
29
38
|
|
|
30
39
|
return &cli.Command{
|
|
31
40
|
Name: "test",
|
|
32
41
|
Category: "test",
|
|
33
42
|
Usage: "compile and run Go package tests through GoScript",
|
|
34
|
-
Action: func(c *cli.Context) error {
|
|
43
|
+
Action: func(c *cli.Context) (err error) {
|
|
35
44
|
req := &gotest.Request{
|
|
36
|
-
Dir:
|
|
37
|
-
Patterns:
|
|
38
|
-
BuildTags:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
Dir: dir,
|
|
46
|
+
Patterns: c.Args().Slice(),
|
|
47
|
+
BuildTags: tags.Value(),
|
|
48
|
+
OverrideDirs: overrideDirs.Value(),
|
|
49
|
+
Run: run,
|
|
50
|
+
Count: count,
|
|
51
|
+
Short: short,
|
|
52
|
+
Timeout: timeout,
|
|
53
|
+
Verbose: verbose,
|
|
54
|
+
WorkDir: workDir,
|
|
55
|
+
OutputRoot: outputRoot,
|
|
56
|
+
Parallelism: parallelism,
|
|
57
|
+
RuntimeGroups: runtimeGroups,
|
|
58
|
+
IncrementalTypeCheck: incrementalTypeCheck,
|
|
46
59
|
}
|
|
60
|
+
stopProfile, err := startCPUProfile(cpuProfile)
|
|
61
|
+
if err != nil {
|
|
62
|
+
return err
|
|
63
|
+
}
|
|
64
|
+
if stopProfile != nil {
|
|
65
|
+
defer stopProfile()
|
|
66
|
+
}
|
|
67
|
+
defer func() {
|
|
68
|
+
if profileErr := writeMemProfile(memProfile); profileErr != nil && err == nil {
|
|
69
|
+
err = profileErr
|
|
70
|
+
}
|
|
71
|
+
}()
|
|
47
72
|
result, err := gotest.NewRunner().Run(c.Context, req)
|
|
48
73
|
if err != nil {
|
|
49
74
|
return err
|
|
@@ -62,6 +87,12 @@ func newTestCommand() *cli.Command {
|
|
|
62
87
|
Usage: "comma-separated Go build tags",
|
|
63
88
|
Destination: &tags,
|
|
64
89
|
},
|
|
90
|
+
&cli.StringSliceFlag{
|
|
91
|
+
Name: "gs-path",
|
|
92
|
+
Aliases: []string{"override-dir"},
|
|
93
|
+
Usage: "additional GoScript override root containing package-path directories",
|
|
94
|
+
Destination: &overrideDirs,
|
|
95
|
+
},
|
|
65
96
|
&cli.StringFlag{
|
|
66
97
|
Name: "run",
|
|
67
98
|
Usage: "run only tests matching the regexp",
|
|
@@ -105,10 +136,72 @@ func newTestCommand() *cli.Command {
|
|
|
105
136
|
Usage: "Go module working directory",
|
|
106
137
|
Destination: &dir,
|
|
107
138
|
},
|
|
139
|
+
&cli.IntFlag{
|
|
140
|
+
Name: "p",
|
|
141
|
+
Usage: "maximum package typecheck/runtime commands to run concurrently",
|
|
142
|
+
Destination: ¶llelism,
|
|
143
|
+
Value: gotest.DefaultParallelism(),
|
|
144
|
+
},
|
|
145
|
+
&cli.BoolFlag{
|
|
146
|
+
Name: "runtime-groups",
|
|
147
|
+
Usage: "run package runtimes in grouped Bun worker processes",
|
|
148
|
+
Destination: &runtimeGroups,
|
|
149
|
+
},
|
|
150
|
+
&cli.BoolFlag{
|
|
151
|
+
Name: "incremental-typecheck",
|
|
152
|
+
Usage: "reuse TypeScript build-info files in the test workdir",
|
|
153
|
+
Destination: &incrementalTypeCheck,
|
|
154
|
+
},
|
|
155
|
+
&cli.StringFlag{
|
|
156
|
+
Name: "cpuprofile",
|
|
157
|
+
Usage: "write a Go CPU profile for the goscript test process",
|
|
158
|
+
Destination: &cpuProfile,
|
|
159
|
+
},
|
|
160
|
+
&cli.StringFlag{
|
|
161
|
+
Name: "memprofile",
|
|
162
|
+
Usage: "write a Go heap profile for the goscript test process",
|
|
163
|
+
Destination: &memProfile,
|
|
164
|
+
},
|
|
108
165
|
},
|
|
109
166
|
}
|
|
110
167
|
}
|
|
111
168
|
|
|
169
|
+
func startCPUProfile(path string) (func(), error) {
|
|
170
|
+
path = strings.TrimSpace(path)
|
|
171
|
+
if path == "" {
|
|
172
|
+
return nil, nil
|
|
173
|
+
}
|
|
174
|
+
file, err := os.Create(path)
|
|
175
|
+
if err != nil {
|
|
176
|
+
return nil, errors.Wrap(err, "create CPU profile")
|
|
177
|
+
}
|
|
178
|
+
if err := pprof.StartCPUProfile(file); err != nil {
|
|
179
|
+
_ = file.Close()
|
|
180
|
+
return nil, errors.Wrap(err, "start CPU profile")
|
|
181
|
+
}
|
|
182
|
+
return func() {
|
|
183
|
+
pprof.StopCPUProfile()
|
|
184
|
+
_ = file.Close()
|
|
185
|
+
}, nil
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
func writeMemProfile(path string) error {
|
|
189
|
+
path = strings.TrimSpace(path)
|
|
190
|
+
if path == "" {
|
|
191
|
+
return nil
|
|
192
|
+
}
|
|
193
|
+
file, err := os.Create(path)
|
|
194
|
+
if err != nil {
|
|
195
|
+
return errors.Wrap(err, "create memory profile")
|
|
196
|
+
}
|
|
197
|
+
defer func() { _ = file.Close() }()
|
|
198
|
+
runtime.GC()
|
|
199
|
+
if err := pprof.WriteHeapProfile(file); err != nil {
|
|
200
|
+
return errors.Wrap(err, "write memory profile")
|
|
201
|
+
}
|
|
202
|
+
return nil
|
|
203
|
+
}
|
|
204
|
+
|
|
112
205
|
func printTestResult(ctx context.Context, w io.Writer, result *gotest.Result) error {
|
|
113
206
|
if err := ctx.Err(); err != nil {
|
|
114
207
|
return err
|
|
@@ -17,7 +17,7 @@ func TestTestCommandHelp(t *testing.T) {
|
|
|
17
17
|
t.Fatalf("test help failed: %v", err)
|
|
18
18
|
}
|
|
19
19
|
help := out.String()
|
|
20
|
-
for _, expected := range []string{"compile and run Go package tests through GoScript", "--tags", "--run", "--count", "--short", "--timeout"} {
|
|
20
|
+
for _, expected := range []string{"compile and run Go package tests through GoScript", "--tags", "--run", "--count", "--short", "--timeout", "-p", "--runtime-groups", "--cpuprofile", "--memprofile"} {
|
|
21
21
|
if !strings.Contains(help, expected) {
|
|
22
22
|
t.Fatalf("help output missing %q:\n%s", expected, help)
|
|
23
23
|
}
|
|
@@ -18,6 +18,7 @@ func newCompileCommand() *cli.Command {
|
|
|
18
18
|
var config compiler.Config
|
|
19
19
|
var packages cli.StringSlice
|
|
20
20
|
var buildFlags cli.StringSlice
|
|
21
|
+
var overrideDirs cli.StringSlice
|
|
21
22
|
|
|
22
23
|
return &cli.Command{
|
|
23
24
|
Name: "compile",
|
|
@@ -25,6 +26,7 @@ func newCompileCommand() *cli.Command {
|
|
|
25
26
|
Usage: "compile a Go package to TypeScript",
|
|
26
27
|
Action: func(c *cli.Context) error {
|
|
27
28
|
config.BuildFlags = slices.Clone(buildFlags.Value())
|
|
29
|
+
config.OverrideDirs = slices.Clone(overrideDirs.Value())
|
|
28
30
|
return compilePackage(c.Context, &config, packages.Value())
|
|
29
31
|
},
|
|
30
32
|
Flags: []cli.Flag{
|
|
@@ -56,6 +58,13 @@ func newCompileCommand() *cli.Command {
|
|
|
56
58
|
Destination: &buildFlags,
|
|
57
59
|
EnvVars: []string{"GOSCRIPT_BUILD_FLAGS"},
|
|
58
60
|
},
|
|
61
|
+
&cli.StringSliceFlag{
|
|
62
|
+
Name: "gs-path",
|
|
63
|
+
Aliases: []string{"override-dir"},
|
|
64
|
+
Usage: "additional GoScript override root containing package-path directories",
|
|
65
|
+
Destination: &overrideDirs,
|
|
66
|
+
EnvVars: []string{"GOSCRIPT_GS_PATH"},
|
|
67
|
+
},
|
|
59
68
|
&cli.BoolFlag{
|
|
60
69
|
Name: "disable-emit-builtin",
|
|
61
70
|
Usage: "disable emitting built-in packages that have handwritten equivalents",
|
|
@@ -36,6 +36,8 @@ type CompileRequest struct {
|
|
|
36
36
|
OutputPath string
|
|
37
37
|
// BuildFlags are forwarded to the Go package loader.
|
|
38
38
|
BuildFlags []string
|
|
39
|
+
// OverrideDirs are additional GoScript override roots.
|
|
40
|
+
OverrideDirs []string
|
|
39
41
|
// DependencyMode controls whether dependencies are included in the graph.
|
|
40
42
|
DependencyMode DependencyMode
|
|
41
43
|
// RuntimeEmissionMode controls runtime package emission policy.
|
|
@@ -77,6 +79,7 @@ func (o *CompileRequestOwner) NewRequest(conf Config, patterns []string) *Compil
|
|
|
77
79
|
Dir: strings.TrimSpace(dir),
|
|
78
80
|
OutputPath: strings.TrimSpace(conf.OutputPath),
|
|
79
81
|
BuildFlags: append([]string(nil), conf.BuildFlags...),
|
|
82
|
+
OverrideDirs: append([]string(nil), conf.OverrideDirs...),
|
|
80
83
|
DependencyMode: dependencyMode,
|
|
81
84
|
RuntimeEmissionMode: runtimeEmissionMode,
|
|
82
85
|
AllDependencies: conf.AllDependencies,
|
|
@@ -165,6 +168,34 @@ func (o *CompileRequestOwner) Validate(req *CompileRequest) []Diagnostic {
|
|
|
165
168
|
})
|
|
166
169
|
}
|
|
167
170
|
}
|
|
171
|
+
for _, dir := range req.OverrideDirs {
|
|
172
|
+
dir = strings.TrimSpace(dir)
|
|
173
|
+
if dir == "" {
|
|
174
|
+
diagnostics = append(diagnostics, Diagnostic{
|
|
175
|
+
Severity: DiagnosticSeverityError,
|
|
176
|
+
Code: "goscript/request:empty-override-dir",
|
|
177
|
+
Message: "override directories must not be empty",
|
|
178
|
+
})
|
|
179
|
+
continue
|
|
180
|
+
}
|
|
181
|
+
info, err := os.Stat(dir)
|
|
182
|
+
switch {
|
|
183
|
+
case err != nil:
|
|
184
|
+
diagnostics = append(diagnostics, Diagnostic{
|
|
185
|
+
Severity: DiagnosticSeverityError,
|
|
186
|
+
Code: "goscript/request:override-dir",
|
|
187
|
+
Message: "override directory is not readable",
|
|
188
|
+
Detail: err.Error(),
|
|
189
|
+
})
|
|
190
|
+
case !info.IsDir():
|
|
191
|
+
diagnostics = append(diagnostics, Diagnostic{
|
|
192
|
+
Severity: DiagnosticSeverityError,
|
|
193
|
+
Code: "goscript/request:override-dir",
|
|
194
|
+
Message: "override path must be a directory",
|
|
195
|
+
Detail: dir,
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
}
|
|
168
199
|
|
|
169
200
|
for _, pattern := range req.Patterns {
|
|
170
201
|
trimmed := strings.TrimSpace(pattern)
|
package/compiler/compiler.go
CHANGED
|
@@ -127,7 +127,6 @@ var expectedV2ComplianceGaps = map[string]bool{
|
|
|
127
127
|
"chan_type_assertion": true,
|
|
128
128
|
"debug_marshal": true,
|
|
129
129
|
"debug_simple": true,
|
|
130
|
-
"embedded_interface_null_assertion": true,
|
|
131
130
|
"filepath_walkfunc_call": true,
|
|
132
131
|
"flag_bitwise_op": true,
|
|
133
132
|
"for_init_multi_assign": true,
|
|
@@ -141,7 +140,6 @@ var expectedV2ComplianceGaps = map[string]bool{
|
|
|
141
140
|
"if_type_assert": true,
|
|
142
141
|
"import_interface": true,
|
|
143
142
|
"index_expr_type_assertion": true,
|
|
144
|
-
"interface_async_method_call": true,
|
|
145
143
|
"interface_embedding": true,
|
|
146
144
|
"interface_type_reference": true,
|
|
147
145
|
"json_debug": true,
|
package/compiler/config.go
CHANGED
|
@@ -16,6 +16,8 @@ type Config struct {
|
|
|
16
16
|
OutputPath string
|
|
17
17
|
// BuildFlags are the Go build flags to use during package loading.
|
|
18
18
|
BuildFlags []string
|
|
19
|
+
// OverrideDirs are additional GoScript override roots.
|
|
20
|
+
OverrideDirs []string
|
|
19
21
|
// AllDependencies controls whether dependencies are included in the graph.
|
|
20
22
|
AllDependencies bool
|
|
21
23
|
// DisableEmitBuiltin controls whether runtime packages are emitted.
|
|
@@ -46,6 +46,8 @@ type PackagePhases struct {
|
|
|
46
46
|
type PackageResult struct {
|
|
47
47
|
// PackagePath is the package under test.
|
|
48
48
|
PackagePath string
|
|
49
|
+
// SourceDir is the package source directory used as the runtime cwd.
|
|
50
|
+
SourceDir string
|
|
49
51
|
// TestPackagePath is the package variant that contains test functions.
|
|
50
52
|
TestPackagePath string
|
|
51
53
|
// TestImports are direct imports from selected test variants.
|
|
@@ -2,6 +2,7 @@ package gotest
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"path/filepath"
|
|
5
|
+
"runtime"
|
|
5
6
|
"slices"
|
|
6
7
|
"strings"
|
|
7
8
|
"time"
|
|
@@ -17,6 +18,8 @@ type Request struct {
|
|
|
17
18
|
Patterns []string
|
|
18
19
|
// BuildTags are normalized into a Go -tags build flag.
|
|
19
20
|
BuildTags []string
|
|
21
|
+
// OverrideDirs are additional GoScript override roots.
|
|
22
|
+
OverrideDirs []string
|
|
20
23
|
// Run is the optional Go test name regexp.
|
|
21
24
|
Run string
|
|
22
25
|
// Count is the number of times to run matched tests.
|
|
@@ -31,19 +34,41 @@ type Request struct {
|
|
|
31
34
|
WorkDir string
|
|
32
35
|
// OutputRoot stores generated TypeScript packages.
|
|
33
36
|
OutputRoot string
|
|
37
|
+
// Parallelism limits concurrent package typecheck/runtime subprocesses.
|
|
38
|
+
Parallelism int
|
|
39
|
+
// RuntimeGroups allows package runtimes to share worker Bun processes.
|
|
40
|
+
RuntimeGroups bool
|
|
41
|
+
// IncrementalTypeCheck reuses TypeScript build-info files inside WorkDir.
|
|
42
|
+
IncrementalTypeCheck bool
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
type normalizedRequest struct {
|
|
37
|
-
Dir
|
|
38
|
-
Patterns
|
|
39
|
-
BuildFlags
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
Dir string
|
|
47
|
+
Patterns []string
|
|
48
|
+
BuildFlags []string
|
|
49
|
+
OverrideDirs []string
|
|
50
|
+
Run string
|
|
51
|
+
Count int
|
|
52
|
+
Short bool
|
|
53
|
+
Timeout time.Duration
|
|
54
|
+
Verbose bool
|
|
55
|
+
WorkDir string
|
|
56
|
+
OutputRoot string
|
|
57
|
+
Parallelism int
|
|
58
|
+
RuntimeGroups bool
|
|
59
|
+
IncrementalTypeCheck bool
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// DefaultParallelism returns the default package subprocess concurrency.
|
|
63
|
+
func DefaultParallelism() int {
|
|
64
|
+
parallelism := runtime.GOMAXPROCS(0)
|
|
65
|
+
if parallelism < 1 {
|
|
66
|
+
return 1
|
|
67
|
+
}
|
|
68
|
+
if parallelism > 8 {
|
|
69
|
+
return 8
|
|
70
|
+
}
|
|
71
|
+
return parallelism
|
|
47
72
|
}
|
|
48
73
|
|
|
49
74
|
func (r *Request) normalize() (*normalizedRequest, error) {
|
|
@@ -78,6 +103,10 @@ func (r *Request) normalize() (*normalizedRequest, error) {
|
|
|
78
103
|
if len(buildTags) != 0 {
|
|
79
104
|
buildFlags = append(buildFlags, "-tags="+strings.Join(buildTags, ","))
|
|
80
105
|
}
|
|
106
|
+
overrideDirs, err := normalizeOverrideDirs(r.OverrideDirs)
|
|
107
|
+
if err != nil {
|
|
108
|
+
return nil, err
|
|
109
|
+
}
|
|
81
110
|
|
|
82
111
|
workDir := strings.TrimSpace(r.WorkDir)
|
|
83
112
|
if workDir != "" {
|
|
@@ -97,20 +126,56 @@ func (r *Request) normalize() (*normalizedRequest, error) {
|
|
|
97
126
|
}
|
|
98
127
|
}
|
|
99
128
|
|
|
129
|
+
parallelism := r.Parallelism
|
|
130
|
+
if parallelism == 0 {
|
|
131
|
+
parallelism = DefaultParallelism()
|
|
132
|
+
}
|
|
133
|
+
if parallelism < 0 {
|
|
134
|
+
return nil, errors.New("test parallelism must be positive")
|
|
135
|
+
}
|
|
136
|
+
|
|
100
137
|
return &normalizedRequest{
|
|
101
|
-
Dir:
|
|
102
|
-
Patterns:
|
|
103
|
-
BuildFlags:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
138
|
+
Dir: absDir,
|
|
139
|
+
Patterns: patterns,
|
|
140
|
+
BuildFlags: buildFlags,
|
|
141
|
+
OverrideDirs: overrideDirs,
|
|
142
|
+
Run: strings.TrimSpace(r.Run),
|
|
143
|
+
Count: count,
|
|
144
|
+
Short: r.Short,
|
|
145
|
+
Timeout: r.Timeout,
|
|
146
|
+
Verbose: r.Verbose,
|
|
147
|
+
WorkDir: workDir,
|
|
148
|
+
OutputRoot: outputRoot,
|
|
149
|
+
Parallelism: parallelism,
|
|
150
|
+
RuntimeGroups: r.RuntimeGroups,
|
|
151
|
+
IncrementalTypeCheck: r.IncrementalTypeCheck,
|
|
111
152
|
}, nil
|
|
112
153
|
}
|
|
113
154
|
|
|
155
|
+
func normalizeOverrideDirs(dirs []string) ([]string, error) {
|
|
156
|
+
if len(dirs) == 0 {
|
|
157
|
+
return nil, nil
|
|
158
|
+
}
|
|
159
|
+
var normalized []string
|
|
160
|
+
seen := make(map[string]bool)
|
|
161
|
+
for _, dir := range dirs {
|
|
162
|
+
dir = strings.TrimSpace(dir)
|
|
163
|
+
if dir == "" {
|
|
164
|
+
continue
|
|
165
|
+
}
|
|
166
|
+
abs, err := filepath.Abs(dir)
|
|
167
|
+
if err != nil {
|
|
168
|
+
return nil, errors.Wrap(err, "resolve override directory")
|
|
169
|
+
}
|
|
170
|
+
if seen[abs] {
|
|
171
|
+
continue
|
|
172
|
+
}
|
|
173
|
+
seen[abs] = true
|
|
174
|
+
normalized = append(normalized, abs)
|
|
175
|
+
}
|
|
176
|
+
return normalized, nil
|
|
177
|
+
}
|
|
178
|
+
|
|
114
179
|
func normalizePatterns(patterns []string) []string {
|
|
115
180
|
if len(patterns) == 0 {
|
|
116
181
|
return nil
|