typenative 0.7.0 → 0.7.1
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/bin/node/assert.js +2 -2
- package/bin/node/child_process.js +66 -8
- package/bin/node/fs.js +1012 -4
- package/bin/node/histogram.js +1991 -0
- package/bin/node/process.js +14 -2
- package/bin/node/sqlite.js +1488 -5
- package/bin/node/stream.js +2 -1
- package/bin/node/system_extra.js +3 -270
- package/bin/node/test.js +39 -1
- package/bin/node/test_report.js +47 -1
- package/bin/node/test_run.js +57 -2
- package/bin/node/util.js +8 -5
- package/bin/node/webassembly.js +20 -5
- package/bin/node/webview.js +3257 -244
- package/bin/node/zlib.js +118 -14
- package/bin/node/zlib_iter.js +585 -0
- package/bin/transpiler.js +1370 -258
- package/bin/version.js +1 -1
- package/govendor/software.sslmate.com/src/go-pkcs12/.gitattributes +10 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/LICENSE +28 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/README.md +31 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/bmp-string.go +63 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/crypto.go +331 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/errors.go +23 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/go.mod +3 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/internal/rc2/rc2.go +271 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/mac.go +202 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/pbkdf.go +184 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/pkcs12.go +1000 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/safebags.go +107 -0
- package/package.json +10 -1
- package/types/tsconfig.json +17 -0
- package/types/typenative-npm.d.ts +492 -12
- package/types/typenative.d.ts +88 -2
- package/.gitattributes +0 -1
- package/.github/workflows/ci.yml +0 -68
- package/.github/workflows/npm-publish-github-packages.yml +0 -88
- package/CHANGELOG.md +0 -1746
- package/CONTRIBUTION.md +0 -133
- package/conformance.md +0 -1497
- package/examples/README.md +0 -114
- package/examples/angular-templates/README.md +0 -141
- package/examples/angular-templates/bench.mjs +0 -173
- package/examples/angular-templates/dom-type-globals.d.ts +0 -21
- package/examples/angular-templates/dom-type-stubs.ts +0 -21
- package/examples/angular-templates/main.ts +0 -135
- package/examples/angular-templates/parity.mjs +0 -157
- package/examples/angular-templates/run-node.mjs +0 -69
- package/examples/angular-templates/vendor/angular/compiler/LICENSE +0 -21
- package/examples/desktop-notes/README.md +0 -106
- package/examples/desktop-notes/bench.mjs +0 -125
- package/examples/desktop-notes/main.ts +0 -131
- package/examples/desktop-notes/package-lock.json +0 -726
- package/examples/desktop-notes/package.json +0 -9
- package/examples/desktop-notes/ui.ts +0 -176
- package/examples/dupe-finder/README.md +0 -78
- package/examples/dupe-finder/bench.mjs +0 -120
- package/examples/dupe-finder/main.ts +0 -87
- package/examples/fibonacci/README.md +0 -89
- package/examples/fibonacci/bench.mjs +0 -87
- package/examples/fibonacci/main.ts +0 -21
- package/examples/hello-world/README.md +0 -62
- package/examples/hello-world/bench.mjs +0 -66
- package/examples/hello-world/main.ts +0 -7
- package/examples/json-server/README.md +0 -132
- package/examples/json-server/bench.mjs +0 -263
- package/examples/json-server/main.ts +0 -67
- package/examples/mandelbrot-png/README.md +0 -63
- package/examples/mandelbrot-png/bench.mjs +0 -95
- package/examples/mandelbrot-png/main.ts +0 -98
- package/examples/mandelbrot-png/preview.png +0 -0
- package/examples/marked-cli/README.md +0 -174
- package/examples/marked-cli/bench.mjs +0 -178
- package/examples/marked-cli/main.ts +0 -410
- package/examples/marked-cli/parity.mjs +0 -185
- package/examples/marked-cli/vendor/marked/LICENSE +0 -44
- package/examples/marked-cli/vendor/marked/VENDOR.md +0 -26
- package/examples/openai-chat/README.md +0 -148
- package/examples/openai-chat/bench.mjs +0 -175
- package/examples/openai-chat/main.ts +0 -488
- package/examples/react-compiler/README.md +0 -185
- package/examples/react-compiler/bench.mjs +0 -181
- package/examples/react-compiler/main.ts +0 -324
- package/examples/react-compiler/parity.mjs +0 -362
- package/examples/react-compiler/run-node.mjs +0 -90
- package/examples/react-compiler/vendor/babel/LICENSE +0 -22
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +0 -15
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +0 -51
- package/examples/react-compiler/vendor/charcodes/package.json +0 -25
- package/examples/react-compiler/vendor/invariant/LICENSE +0 -21
- package/examples/react-compiler/vendor/invariant/invariant.cjs +0 -51
- package/examples/react-compiler/vendor/invariant/invariant.d.cts +0 -11
- package/examples/react-compiler/vendor/invariant/types/LICENSE +0 -21
- package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +0 -19
- package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +0 -19
- package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +0 -19
- package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +0 -19
- package/examples/react-compiler/vendor/js-tokens/LICENSE +0 -21
- package/examples/react-compiler/vendor/js-tokens/index.cjs +0 -23
- package/examples/react-compiler/vendor/js-tokens/index.d.cts +0 -13
- package/examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt +0 -20
- package/examples/react-compiler/vendor/jsesc/jsesc.cjs +0 -337
- package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +0 -384
- package/examples/react-compiler/vendor/jsesc/types/LICENSE +0 -21
- package/examples/react-compiler/vendor/picocolors/LICENSE +0 -15
- package/examples/react-compiler/vendor/picocolors/picocolors.cjs +0 -75
- package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +0 -5
- package/examples/react-compiler/vendor/picocolors/types.d.ts +0 -51
- package/examples/react-compiler/vendor/react-compiler/LICENSE +0 -21
- package/examples/react-compiler/vendor/stubs/babel-core.ts +0 -31
- package/examples/react-compiler/vendor/stubs/debug.ts +0 -18
- package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +0 -13
- package/examples/react-compiler/vendor/stubs/pretty-format.ts +0 -18
- package/examples/react-compiler/vendor/zod/LICENSE +0 -21
- package/examples/react-compiler/vendor/zod-validation-error/LICENSE +0 -9
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +0 -5
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +0 -49
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +0 -48
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +0 -50
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +0 -6
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +0 -126
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +0 -39
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +0 -78
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +0 -2
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +0 -131
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +0 -54
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +0 -40
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +0 -76
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +0 -76
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +0 -27
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +0 -27
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +0 -13
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +0 -61
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +0 -38
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +0 -20
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +0 -5
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +0 -8
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +0 -11
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +0 -20
- package/examples/react-compiler/vendor.mjs +0 -688
- package/examples/todo-cli/README.md +0 -69
- package/examples/todo-cli/bench.mjs +0 -89
- package/examples/todo-cli/main.ts +0 -92
- package/examples/yaml-cli/README.md +0 -152
- package/examples/yaml-cli/bench.mjs +0 -265
- package/examples/yaml-cli/main.ts +0 -251
- package/examples/yaml-cli/parity.mjs +0 -156
- package/examples/yaml-cli/vendor/yaml/LICENSE +0 -13
- package/examples/yaml-cli/vendor/yaml/VENDOR.md +0 -25
- package/performance/README.md +0 -248
- package/performance/any-dynamic.ts +0 -21
- package/performance/any-record-view.ts +0 -20
- package/performance/arr-for-of.ts +0 -29
- package/performance/arr-hof.ts +0 -21
- package/performance/arr-push-index.ts +0 -15
- package/performance/arr-push-local.ts +0 -39
- package/performance/arr-slice-concat.ts +0 -24
- package/performance/arr-sort.ts +0 -21
- package/performance/async-await.ts +0 -24
- package/performance/async-promise-all.ts +0 -38
- package/performance/bigint-arith.ts +0 -36
- package/performance/buf-encode.ts +0 -29
- package/performance/class-accessors.ts +0 -48
- package/performance/class-dispatch.ts +0 -52
- package/performance/date-format.ts +0 -18
- package/performance/events-emit.ts +0 -27
- package/performance/exc-throw-rare.ts +0 -25
- package/performance/exc-try-catch.ts +0 -26
- package/performance/fn-closures.ts +0 -29
- package/performance/fn-recursion-tree.ts +0 -31
- package/performance/fn-rest-spread.ts +0 -43
- package/performance/gen-for-of.ts +0 -46
- package/performance/gen-next.ts +0 -32
- package/performance/iter-helpers.ts +0 -38
- package/performance/json-any.ts +0 -30
- package/performance/json-roundtrip.ts +0 -27
- package/performance/map-delete.ts +0 -24
- package/performance/map-iterate.ts +0 -26
- package/performance/map-number-keys.ts +0 -37
- package/performance/map-string-keys.ts +0 -22
- package/performance/num-arith-loop.ts +0 -14
- package/performance/num-bitwise.ts +0 -21
- package/performance/num-hash-imul.ts +0 -36
- package/performance/num-mod-int.ts +0 -16
- package/performance/num-to-string.ts +0 -16
- package/performance/obj-alloc.ts +0 -32
- package/performance/obj-keys-entries.ts +0 -44
- package/performance/obj-optional-chain.ts +0 -42
- package/performance/obj-record-dict.ts +0 -24
- package/performance/obj-spread-destructure.ts +0 -40
- package/performance/regex-exec.ts +0 -29
- package/performance/regex-replace-fn.ts +0 -24
- package/performance/regex-site.ts +0 -28
- package/performance/set-ops.ts +0 -20
- package/performance/str-char-scan.ts +0 -35
- package/performance/str-concat-plus.ts +0 -18
- package/performance/str-concat.ts +0 -24
- package/performance/str-methods.ts +0 -24
- package/performance/str-short-scan.ts +0 -26
- package/performance/str-split-join.ts +0 -23
- package/performance/str-switch-compare.ts +0 -50
- package/performance/str-template.ts +0 -16
- package/performance/str-unicode.ts +0 -25
- package/performance/typed-array.ts +0 -30
- package/performance/union-switch.ts +0 -57
- package/performance/union-typeof.ts +0 -40
- package/performance/wasm-call.ts +0 -63
- package/tsparser/check.go +0 -158
- package/tsparser/go.mod +0 -14
- package/tsparser/go.sum +0 -22
- package/tsparser/main.go +0 -363
- package/tsparser/tsparser.exe +0 -4
package/bin/node/stream.js
CHANGED
|
@@ -1014,6 +1014,7 @@ func TnReadableFrom(iterable interface{}, options ...interface{}) *TnStream {
|
|
|
1014
1014
|
TnLoopRef()
|
|
1015
1015
|
go func() {
|
|
1016
1016
|
for {
|
|
1017
|
+
TnGenWake(iterable)
|
|
1017
1018
|
v, ok := rv.Recv()
|
|
1018
1019
|
if !ok {
|
|
1019
1020
|
break
|
|
@@ -1600,7 +1601,7 @@ export function registerStream(r) {
|
|
|
1600
1601
|
defineModule(r, mod);
|
|
1601
1602
|
r.namespaces['stream.promises'] = 'stream/promises';
|
|
1602
1603
|
r.namespaces['stream.default'] = 'stream.Stream';
|
|
1603
|
-
defineHelper(r, 'nodeStream', ['encoding/json', 'math/big', 'os', 'reflect', 'strconv', 'unicode/utf8'], ['nodeEvents', 'buffer', 'stringDecoder', 'eventLoop', 'promise', 'dynamic', 'nodeInvoke', 'stdinReader'], streamHelper);
|
|
1604
|
+
defineHelper(r, 'nodeStream', ['encoding/json', 'math/big', 'os', 'reflect', 'strconv', 'unicode/utf8'], ['nodeEvents', 'buffer', 'stringDecoder', 'eventLoop', 'promise', 'dynamic', 'nodeInvoke', 'stdinReader', 'generatorStep'], streamHelper);
|
|
1604
1605
|
defineHelper(r, 'stdinReader', ['bufio', 'os'], [], `// One buffered reader shared by process.stdin, readline and question()
|
|
1605
1606
|
var tnStdinBuffered *bufio.Reader
|
|
1606
1607
|
|
package/bin/node/system_extra.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// loadavg / release / version; perf_hooks PerformanceObserver, timerify,
|
|
5
5
|
// createHistogram, monitorEventLoopDelay, eventLoopUtilization.
|
|
6
6
|
import { defineClass, defineHelper, setResults } from './registry.js';
|
|
7
|
+
import { registerHistogram } from './histogram.js';
|
|
7
8
|
const uncaughtHelper = `// process.on('uncaughtException') & co.
|
|
8
9
|
// set/addUncaughtExceptionCaptureCallback: the set one takes every error; an
|
|
9
10
|
// added one takes it when it returns true
|
|
@@ -432,270 +433,6 @@ func TnPerfTimerify[F any](fn F, name string) F {
|
|
|
432
433
|
return wrapped.Interface().(F)
|
|
433
434
|
}
|
|
434
435
|
|
|
435
|
-
// Histograms (createHistogram / monitorEventLoopDelay): values in nanoseconds
|
|
436
|
-
type TnHistogram struct {
|
|
437
|
-
values []float64
|
|
438
|
-
exceeds float64
|
|
439
|
-
enabled bool
|
|
440
|
-
stop chan struct{}
|
|
441
|
-
interval float64
|
|
442
|
-
last time.Time
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
func TnCreateHistogram(options ...interface{}) *TnHistogram { return &TnHistogram{} }
|
|
446
|
-
|
|
447
|
-
func (h *TnHistogram) record(value interface{}) {
|
|
448
|
-
switch v := value.(type) {
|
|
449
|
-
case float64:
|
|
450
|
-
h.values = append(h.values, v)
|
|
451
|
-
case *tnbig.Int:
|
|
452
|
-
f, _ := new(tnbig.Float).SetInt(v).Float64()
|
|
453
|
-
h.values = append(h.values, f)
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
func (h *TnHistogram) recordDelta() {
|
|
458
|
-
now := time.Now()
|
|
459
|
-
if !h.last.IsZero() {
|
|
460
|
-
h.values = append(h.values, float64(now.Sub(h.last).Nanoseconds()))
|
|
461
|
-
}
|
|
462
|
-
h.last = now
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
func (h *TnHistogram) sorted() []float64 {
|
|
466
|
-
out := append([]float64{}, h.values...)
|
|
467
|
-
sort.Float64s(out)
|
|
468
|
-
return out
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
func (h *TnHistogram) Get_count() float64 { return float64(len(h.values)) }
|
|
472
|
-
func (h *TnHistogram) Get_min() float64 {
|
|
473
|
-
if len(h.values) == 0 {
|
|
474
|
-
return 9223372036854776000
|
|
475
|
-
}
|
|
476
|
-
return h.sorted()[0]
|
|
477
|
-
}
|
|
478
|
-
func (h *TnHistogram) Get_max() float64 {
|
|
479
|
-
if len(h.values) == 0 {
|
|
480
|
-
return 0
|
|
481
|
-
}
|
|
482
|
-
s := h.sorted()
|
|
483
|
-
return s[len(s)-1]
|
|
484
|
-
}
|
|
485
|
-
func (h *TnHistogram) Get_mean() float64 {
|
|
486
|
-
if len(h.values) == 0 {
|
|
487
|
-
return math.NaN()
|
|
488
|
-
}
|
|
489
|
-
sum := 0.0
|
|
490
|
-
for _, v := range h.values {
|
|
491
|
-
sum += v
|
|
492
|
-
}
|
|
493
|
-
return sum / float64(len(h.values))
|
|
494
|
-
}
|
|
495
|
-
func (h *TnHistogram) Get_stddev() float64 {
|
|
496
|
-
if len(h.values) == 0 {
|
|
497
|
-
return math.NaN()
|
|
498
|
-
}
|
|
499
|
-
mean := h.Get_mean()
|
|
500
|
-
sum := 0.0
|
|
501
|
-
for _, v := range h.values {
|
|
502
|
-
sum += (v - mean) * (v - mean)
|
|
503
|
-
}
|
|
504
|
-
return math.Sqrt(sum / float64(len(h.values)))
|
|
505
|
-
}
|
|
506
|
-
func (h *TnHistogram) Get_exceeds() float64 { return h.exceeds }
|
|
507
|
-
|
|
508
|
-
func (h *TnHistogram) percentile(p float64) float64 {
|
|
509
|
-
if len(h.values) == 0 {
|
|
510
|
-
return 0
|
|
511
|
-
}
|
|
512
|
-
s := h.sorted()
|
|
513
|
-
i := int(math.Ceil(p/100*float64(len(s)))) - 1
|
|
514
|
-
if i < 0 {
|
|
515
|
-
i = 0
|
|
516
|
-
}
|
|
517
|
-
if i >= len(s) {
|
|
518
|
-
i = len(s) - 1
|
|
519
|
-
}
|
|
520
|
-
return s[i]
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
func (h *TnHistogram) Get_percentiles() *TnMap[float64, float64] {
|
|
524
|
-
m := TnNewMap[float64, float64]()
|
|
525
|
-
for _, p := range []float64{0, 50, 75, 87.5, 93.75, 96.875, 98.4375, 99.21875, 100} {
|
|
526
|
-
m.Set(p, h.percentile(p))
|
|
527
|
-
}
|
|
528
|
-
return m
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
// Node 26 histogram statistics over the recorded values
|
|
532
|
-
func (h *TnHistogram) countAt(v float64) float64 {
|
|
533
|
-
n := 0
|
|
534
|
-
for _, x := range h.values {
|
|
535
|
-
if x == v {
|
|
536
|
-
n++
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
return float64(n)
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// cdf(v): the share of values at or below v; ccdf(v): above it
|
|
543
|
-
func (h *TnHistogram) cdf(v float64) float64 {
|
|
544
|
-
if len(h.values) == 0 {
|
|
545
|
-
return 0
|
|
546
|
-
}
|
|
547
|
-
n := 0
|
|
548
|
-
for _, x := range h.values {
|
|
549
|
-
if x <= v {
|
|
550
|
-
n++
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
return float64(n) / float64(len(h.values))
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
func (h *TnHistogram) ccdf(v float64) float64 {
|
|
557
|
-
if len(h.values) == 0 {
|
|
558
|
-
return 0
|
|
559
|
-
}
|
|
560
|
-
return 1 - h.cdf(v)
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// The population's central moments m2, m3, m4
|
|
564
|
-
func (h *TnHistogram) moments() (float64, float64, float64) {
|
|
565
|
-
n := float64(len(h.values))
|
|
566
|
-
if n == 0 {
|
|
567
|
-
return 0, 0, 0
|
|
568
|
-
}
|
|
569
|
-
mean := h.Get_mean()
|
|
570
|
-
var m2, m3, m4 float64
|
|
571
|
-
for _, x := range h.values {
|
|
572
|
-
d := x - mean
|
|
573
|
-
m2 += d * d
|
|
574
|
-
m3 += d * d * d
|
|
575
|
-
m4 += d * d * d * d
|
|
576
|
-
}
|
|
577
|
-
return m2 / n, m3 / n, m4 / n
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
func (h *TnHistogram) Get_skewness() float64 {
|
|
581
|
-
m2, m3, _ := h.moments()
|
|
582
|
-
if m2 == 0 {
|
|
583
|
-
return 0
|
|
584
|
-
}
|
|
585
|
-
return m3 / math.Pow(m2, 1.5)
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// kurtosis: the excess kurtosis (a normal distribution's is 0)
|
|
589
|
-
func (h *TnHistogram) Get_kurtosis() float64 {
|
|
590
|
-
m2, _, m4 := h.moments()
|
|
591
|
-
if m2 == 0 {
|
|
592
|
-
return 0
|
|
593
|
-
}
|
|
594
|
-
return m4/(m2*m2) - 3
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
// recordCorrected(value, expectedInterval): the samples a stalled recorder
|
|
598
|
-
// missed are added too (value - interval, value - 2·interval, …)
|
|
599
|
-
func (h *TnHistogram) recordCorrected(value interface{}, interval float64) {
|
|
600
|
-
h.record(value)
|
|
601
|
-
v, ok := value.(float64)
|
|
602
|
-
if !ok || interval <= 0 {
|
|
603
|
-
return
|
|
604
|
-
}
|
|
605
|
-
for missing := v - interval; missing >= interval; missing -= interval {
|
|
606
|
-
h.values = append(h.values, missing)
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// add(other) / subtract(other): other's values merged in or taken out
|
|
611
|
-
func (h *TnHistogram) add(other *TnHistogram) {
|
|
612
|
-
h.values = append(h.values, other.values...)
|
|
613
|
-
h.exceeds += other.exceeds
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
func (h *TnHistogram) subtract(other *TnHistogram) {
|
|
617
|
-
for _, v := range other.values {
|
|
618
|
-
for i, x := range h.values {
|
|
619
|
-
if x == v {
|
|
620
|
-
h.values = append(h.values[:i], h.values[i+1:]...)
|
|
621
|
-
break
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
// snapshot(): the statistics as a plain object
|
|
628
|
-
func (h *TnHistogram) snapshot() *TnMap[string, interface{}] {
|
|
629
|
-
m := TnNewMap[string, interface{}]()
|
|
630
|
-
m.Set("count", h.Get_count())
|
|
631
|
-
m.Set("min", h.Get_min())
|
|
632
|
-
m.Set("max", h.Get_max())
|
|
633
|
-
m.Set("mean", h.Get_mean())
|
|
634
|
-
m.Set("exceeds", h.Get_exceeds())
|
|
635
|
-
m.Set("stddev", h.Get_stddev())
|
|
636
|
-
m.Set("skewness", h.Get_skewness())
|
|
637
|
-
m.Set("kurtosis", h.Get_kurtosis())
|
|
638
|
-
percentiles := TnNewMap[string, interface{}]()
|
|
639
|
-
pm := h.Get_percentiles()
|
|
640
|
-
for _, k := range pm.Keys() {
|
|
641
|
-
percentiles.Set(TnNumStr(k), pm.Get(k))
|
|
642
|
-
}
|
|
643
|
-
m.Set("percentiles", percentiles)
|
|
644
|
-
return m
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
func (h *TnHistogram) reset() {
|
|
648
|
-
h.values = nil
|
|
649
|
-
h.exceeds = 0
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// monitorEventLoopDelay({ resolution }): samples how late a timer fires on the loop
|
|
653
|
-
func TnMonitorEventLoopDelay(options ...interface{}) *TnHistogram {
|
|
654
|
-
h := &TnHistogram{interval: 10}
|
|
655
|
-
if len(options) > 0 && options[0] != nil {
|
|
656
|
-
if n, ok := TnGetValue(options[0], "resolution").(float64); ok && n > 0 {
|
|
657
|
-
h.interval = n
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
return h
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
func (h *TnHistogram) enable() bool {
|
|
664
|
-
if h.enabled {
|
|
665
|
-
return false
|
|
666
|
-
}
|
|
667
|
-
h.enabled = true
|
|
668
|
-
h.stop = make(chan struct{})
|
|
669
|
-
stop := h.stop
|
|
670
|
-
period := time.Duration(h.interval * float64(time.Millisecond))
|
|
671
|
-
go func() {
|
|
672
|
-
ticker := time.NewTicker(period)
|
|
673
|
-
defer ticker.Stop()
|
|
674
|
-
for {
|
|
675
|
-
select {
|
|
676
|
-
case <-stop:
|
|
677
|
-
return
|
|
678
|
-
case expected := <-ticker.C:
|
|
679
|
-
TnLoopPost(func() {
|
|
680
|
-
if h.enabled {
|
|
681
|
-
h.values = append(h.values, math.Max(float64(time.Since(expected).Nanoseconds()), 1))
|
|
682
|
-
}
|
|
683
|
-
})
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}()
|
|
687
|
-
return true
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
func (h *TnHistogram) disable() bool {
|
|
691
|
-
if !h.enabled {
|
|
692
|
-
return false
|
|
693
|
-
}
|
|
694
|
-
h.enabled = false
|
|
695
|
-
close(h.stop)
|
|
696
|
-
return true
|
|
697
|
-
}
|
|
698
|
-
|
|
699
436
|
// eventLoopUtilization(): idle / active time of the loop (approximate: CPU time)
|
|
700
437
|
type TnLoopUtilization struct {
|
|
701
438
|
idle float64
|
|
@@ -765,7 +502,7 @@ export function registerSystemExtra(r) {
|
|
|
765
502
|
defineHelper(r, 'nodeSystemOS@windows', ['syscall', 'unsafe'], [], windowsSystemHelper);
|
|
766
503
|
defineHelper(r, 'nodeSystemOS@other', [], [], otherSystemHelper);
|
|
767
504
|
defineHelper(r, 'nodeSystem', ['math', 'os', 'os/exec', 'runtime', 'runtime/metrics', 'strconv', 'strings', 'time'], ['nodeSystemOS@os'], systemHelper);
|
|
768
|
-
defineHelper(r, 'nodePerfExtra', ['math', '
|
|
505
|
+
defineHelper(r, 'nodePerfExtra', ['math', 'reflect', 'sort'], ['nodePerf', 'nodeSystem', 'eventLoop', 'nodeInvoke', 'dynamic'], perfExtraHelper);
|
|
769
506
|
// uncaught exception capture callbacks
|
|
770
507
|
r.functions['process.setUncaughtExceptionCaptureCallback'] = (c) => {
|
|
771
508
|
r.helper('nodeUncaught');
|
|
@@ -845,12 +582,8 @@ export function registerSystemExtra(r) {
|
|
|
845
582
|
return 'TnPerfObservedTypes()';
|
|
846
583
|
};
|
|
847
584
|
r.valueTypes['perf_hooks.PerformanceObserver.supportedEntryTypes'] = '[]string';
|
|
848
|
-
|
|
849
|
-
for (const name of ['RecordableHistogram', 'IntervalHistogram'])
|
|
850
|
-
r.classes[`perf_hooks.${name}`] = r.classes['perf_hooks.Histogram'];
|
|
585
|
+
registerHistogram(r);
|
|
851
586
|
defineClass(r, 'perf_hooks.EventLoopUtilization', '*TnLoopUtilization', 'class', '', 'idle=float64; active=float64; utilization=float64', '', '');
|
|
852
|
-
fn('perf_hooks.createHistogram', '*TnHistogram', 'nodePerfExtra', (c) => `TnCreateHistogram(${c.args.join(', ')})`);
|
|
853
|
-
fn('perf_hooks.monitorEventLoopDelay', '*TnHistogram', 'nodePerfExtra', (c) => `TnMonitorEventLoopDelay(${c.args.join(', ')})`);
|
|
854
587
|
for (const key of [...perf('performance.timerify'), 'perf_hooks.timerify']) {
|
|
855
588
|
r.functions[key] = (c) => {
|
|
856
589
|
r.helper('nodePerfExtra');
|
package/bin/node/test.js
CHANGED
|
@@ -49,6 +49,7 @@ var tnTestRunning *TnTestNode
|
|
|
49
49
|
var tnTestScheduled bool
|
|
50
50
|
var tnTestStart float64
|
|
51
51
|
var tnTestCounts = map[string]int{}
|
|
52
|
+
var tnTestInterrupted sync.Once
|
|
52
53
|
|
|
53
54
|
// Hooks of the optional parts: a run() child sends its events to the parent;
|
|
54
55
|
// coverage and snapshots finish when the run does
|
|
@@ -770,12 +771,49 @@ func tnTestNote(nesting int, message string, level string, n *TnTestNode) *TnTes
|
|
|
770
771
|
return &TnTestEvent{type_: "test:diagnostic", data: d}
|
|
771
772
|
}
|
|
772
773
|
|
|
774
|
+
func tnFindRunningTests(n *TnTestNode, depth int) []*TnTestEventData {
|
|
775
|
+
var out []*TnTestEventData
|
|
776
|
+
for _, child := range n.children {
|
|
777
|
+
if child.started && child.status == "" {
|
|
778
|
+
sub := tnFindRunningTests(child, depth+1)
|
|
779
|
+
if len(sub) > 0 {
|
|
780
|
+
out = append(out, sub...)
|
|
781
|
+
} else {
|
|
782
|
+
out = append(out, &TnTestEventData{
|
|
783
|
+
name: child.name,
|
|
784
|
+
nesting: float64(depth),
|
|
785
|
+
file: child.file,
|
|
786
|
+
line: child.line,
|
|
787
|
+
column: child.column,
|
|
788
|
+
})
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return out
|
|
793
|
+
}
|
|
794
|
+
|
|
773
795
|
func tnRunRoot() {
|
|
774
796
|
tnTestStart = tnTestNow()
|
|
775
797
|
cfg := tnTestFilters()
|
|
776
798
|
for _, s := range tnTestSinks {
|
|
777
799
|
s.write(s.reporter.begin())
|
|
778
800
|
}
|
|
801
|
+
onInterrupt := func(args ...interface{}) {
|
|
802
|
+
tnTestInterrupted.Do(func() {
|
|
803
|
+
running := tnFindRunningTests(tnTestRoot, 0)
|
|
804
|
+
if len(running) > 0 {
|
|
805
|
+
tnTestEmit(&TnTestEvent{type_: "test:interrupted", data: &TnTestEventData{tests: running}})
|
|
806
|
+
}
|
|
807
|
+
for _, s := range tnTestSinks {
|
|
808
|
+
if s.file {
|
|
809
|
+
s.out.Close()
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
os.Exit(1)
|
|
813
|
+
})
|
|
814
|
+
}
|
|
815
|
+
TnProcessOn("SIGINT", onInterrupt, true)
|
|
816
|
+
defer tnProcessEmitter.off("SIGINT", onInterrupt)
|
|
779
817
|
root := tnTestRoot
|
|
780
818
|
if cfg.active() {
|
|
781
819
|
tnTestPrune(root)
|
|
@@ -1668,7 +1706,7 @@ function eventFn(nodes) {
|
|
|
1668
1706
|
}
|
|
1669
1707
|
export function registerTest(r) {
|
|
1670
1708
|
defineModule(r, 'test');
|
|
1671
|
-
defineHelper(r, 'nodeTest', ['crypto/rand', 'fmt', 'math', 'os', 'path/filepath', 'reflect', 'regexp', 'strconv', 'strings', 'time'], ['eventLoop', 'promise', 'nodeInvoke', 'dynamic', 'nodeEvents', 'nodeProcess', 'nodeUtil', 'nodeAssert', 'arraySubclass', 'error', 'timerWait', 'clock', 'nodeTestReport', 'nodeTestClock@os'], testHelper);
|
|
1709
|
+
defineHelper(r, 'nodeTest', ['crypto/rand', 'fmt', 'math', 'os', 'path/filepath', 'reflect', 'regexp', 'strconv', 'strings', 'sync', 'time'], ['eventLoop', 'promise', 'nodeInvoke', 'dynamic', 'nodeEvents', 'nodeProcess', 'nodeUtil', 'nodeAssert', 'arraySubclass', 'error', 'timerWait', 'clock', 'nodeTestReport', 'nodeTestClock@os'], testHelper);
|
|
1672
1710
|
defineHelper(r, 'nodeTestSnapshot', ['fmt', 'os', 'path/filepath', 'sort', 'strconv', 'strings'], ['nodeTest', 'nodeAssert', 'jsonStringify'], snapshotHelper);
|
|
1673
1711
|
registerTestReporters(r);
|
|
1674
1712
|
registerTestRun(r);
|
package/bin/node/test_report.js
CHANGED
|
@@ -31,6 +31,7 @@ type TnTestEventData struct {
|
|
|
31
31
|
duration_ms float64
|
|
32
32
|
success bool
|
|
33
33
|
summary *TnCoverageSummary
|
|
34
|
+
tests []*TnTestEventData
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
type TnTestEventDetails struct {
|
|
@@ -186,6 +187,24 @@ func tnTestEventOf(v interface{}) *TnTestEvent {
|
|
|
186
187
|
if s := TnGet(raw, "summary"); s != nil {
|
|
187
188
|
d.summary = tnCoverageSummaryOf(s)
|
|
188
189
|
}
|
|
190
|
+
if tests := tnTestList(TnGet(raw, "tests")); tests != nil {
|
|
191
|
+
for _, item := range tests {
|
|
192
|
+
if item == nil {
|
|
193
|
+
continue
|
|
194
|
+
}
|
|
195
|
+
if typed, ok := item.(*TnTestEventData); ok {
|
|
196
|
+
d.tests = append(d.tests, typed)
|
|
197
|
+
} else {
|
|
198
|
+
d.tests = append(d.tests, &TnTestEventData{
|
|
199
|
+
name: tnTestStr(TnGet(item, "name")),
|
|
200
|
+
nesting: tnTestNum(TnGet(item, "nesting")),
|
|
201
|
+
file: tnTestStr(TnGet(item, "file")),
|
|
202
|
+
line: tnTestNum(TnGet(item, "line")),
|
|
203
|
+
column: tnTestNum(TnGet(item, "column")),
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
189
208
|
return e
|
|
190
209
|
}
|
|
191
210
|
|
|
@@ -420,6 +439,14 @@ func (r *tnTapReporter) report(e *TnTestEvent) string {
|
|
|
420
439
|
if d.summary != nil {
|
|
421
440
|
out += tnCoverageReport(indent, d.summary, "# ", "", tnTestPalette{}, true)
|
|
422
441
|
}
|
|
442
|
+
case "test:interrupted":
|
|
443
|
+
for _, t := range d.tests {
|
|
444
|
+
msg := "Interrupted while running: " + t.name
|
|
445
|
+
if t.file != "" {
|
|
446
|
+
msg += " at " + t.file + ":" + TnNumStr(t.line) + ":" + TnNumStr(t.column)
|
|
447
|
+
}
|
|
448
|
+
out += "# " + tnTapEscape(msg) + "\\n"
|
|
449
|
+
}
|
|
423
450
|
}
|
|
424
451
|
return out
|
|
425
452
|
}
|
|
@@ -677,6 +704,25 @@ func (r *tnSpecReporter) report(e *TnTestEvent) string {
|
|
|
677
704
|
if d.file == "" {
|
|
678
705
|
return r.failures()
|
|
679
706
|
}
|
|
707
|
+
case "test:interrupted":
|
|
708
|
+
if len(d.tests) == 0 {
|
|
709
|
+
return ""
|
|
710
|
+
}
|
|
711
|
+
lines := []string{"\\n" + r.p.yellow() + "Interrupted while running:" + r.p.white() + "\\n"}
|
|
712
|
+
for _, t := range d.tests {
|
|
713
|
+
msg := tnSpecIndent(t.nesting) + "\\u26a0 " + t.name
|
|
714
|
+
if t.file != "" {
|
|
715
|
+
rel := t.file
|
|
716
|
+
if r.cwd != "" {
|
|
717
|
+
if p, err := filepath.Rel(r.cwd, t.file); err == nil {
|
|
718
|
+
rel = p
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
msg += " " + r.p.gray() + "(" + rel + ":" + TnNumStr(t.line) + ":" + TnNumStr(t.column) + ")" + r.p.white()
|
|
722
|
+
}
|
|
723
|
+
lines = append(lines, msg)
|
|
724
|
+
}
|
|
725
|
+
return strings.Join(lines, "\\n") + "\\n"
|
|
680
726
|
}
|
|
681
727
|
return ""
|
|
682
728
|
}
|
|
@@ -1347,7 +1393,7 @@ func tnTestNow() float64 { return float64(time.Since(tnTestEpoch).Nanoseconds())
|
|
|
1347
1393
|
const use = () => r.helper('nodeTestReporters');
|
|
1348
1394
|
// Event data, for typed reads in run() listeners (stream.on('test:pass', (data) => …))
|
|
1349
1395
|
defineClass(r, 'test.TestEvent', '*TnTestEvent', 'class', '', 'data=*TnTestEventData', 'type=string', '');
|
|
1350
|
-
defineClass(r, 'test.TestEventData', '*TnTestEventData', 'class', '', 'name=string; nesting=float64; testNumber=float64; details=*TnTestEventDetails; skip=interface{}; todo=interface{}; file=string; line=float64; column=float64; count=float64; message=string; level=string; counts=*TnTestCounts; duration_ms=float64; success=bool; summary=*TnCoverageSummary', '', '');
|
|
1396
|
+
defineClass(r, 'test.TestEventData', '*TnTestEventData', 'class', '', 'name=string; nesting=float64; testNumber=float64; details=*TnTestEventDetails; skip=interface{}; todo=interface{}; file=string; line=float64; column=float64; count=float64; message=string; level=string; counts=*TnTestCounts; duration_ms=float64; success=bool; summary=*TnCoverageSummary; tests=[]*TnTestEventData', '', '');
|
|
1351
1397
|
defineClass(r, 'test.TestEventDetails', '*TnTestEventDetails', 'class', '', 'duration_ms=float64; passed=bool', 'type=string; error=interface{}', '');
|
|
1352
1398
|
defineClass(r, 'test.TestCounts', '*TnTestCounts', 'class', '', 'tests=float64; failed=float64; passed=float64; cancelled=float64; skipped=float64; todo=float64; topLevel=float64; suites=float64', '', '');
|
|
1353
1399
|
const counts = 'totalLineCount=float64; totalBranchCount=float64; totalFunctionCount=float64; coveredLineCount=float64; coveredBranchCount=float64; coveredFunctionCount=float64; coveredLinePercent=float64; coveredBranchPercent=float64; coveredFunctionPercent=float64';
|
package/bin/node/test_run.js
CHANGED
|
@@ -40,8 +40,10 @@ func tnTestWriteFrame(e *TnTestEvent) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
type tnTestRunFile struct {
|
|
43
|
-
entry
|
|
44
|
-
path
|
|
43
|
+
entry string
|
|
44
|
+
path string
|
|
45
|
+
cmd *exec.Cmd
|
|
46
|
+
started bool
|
|
45
47
|
// events held back while an earlier file is still reporting
|
|
46
48
|
held []*TnTestEvent
|
|
47
49
|
finished bool
|
|
@@ -64,6 +66,8 @@ type tnTestRun struct {
|
|
|
64
66
|
coverage []*TnCoverageSummary
|
|
65
67
|
start time.Time
|
|
66
68
|
success bool
|
|
69
|
+
interrupted bool
|
|
70
|
+
onInterrupt interface{}
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
// run(options): files pairs each entry id with the file's path
|
|
@@ -89,6 +93,10 @@ func TnTestRun(options interface{}, files ...[]string) *TnStream {
|
|
|
89
93
|
if r.concurrency < 1 {
|
|
90
94
|
r.concurrency = 1
|
|
91
95
|
}
|
|
96
|
+
r.onInterrupt = func(args ...interface{}) {
|
|
97
|
+
r.interrupt()
|
|
98
|
+
}
|
|
99
|
+
TnProcessOn("SIGINT", r.onInterrupt, true)
|
|
92
100
|
TnLoopRef()
|
|
93
101
|
TnLoopPost(func() {
|
|
94
102
|
if options != nil {
|
|
@@ -102,6 +110,37 @@ func TnTestRun(options interface{}, files ...[]string) *TnStream {
|
|
|
102
110
|
return s
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
func (r *tnTestRun) interrupt() {
|
|
114
|
+
if r.interrupted {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
r.interrupted = true
|
|
118
|
+
if r.onInterrupt != nil {
|
|
119
|
+
tnProcessEmitter.off("SIGINT", r.onInterrupt)
|
|
120
|
+
r.onInterrupt = nil
|
|
121
|
+
}
|
|
122
|
+
var running []*TnTestEventData
|
|
123
|
+
for _, f := range r.files {
|
|
124
|
+
if f.started && !f.finished {
|
|
125
|
+
running = append(running, &TnTestEventData{
|
|
126
|
+
name: f.path,
|
|
127
|
+
nesting: 0,
|
|
128
|
+
file: f.path,
|
|
129
|
+
line: 1,
|
|
130
|
+
column: 1,
|
|
131
|
+
})
|
|
132
|
+
if f.cmd != nil && f.cmd.Process != nil {
|
|
133
|
+
f.cmd.Process.Kill()
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if len(running) > 0 {
|
|
138
|
+
r.emit(&TnTestEvent{type_: "test:interrupted", data: &TnTestEventData{tests: running}})
|
|
139
|
+
}
|
|
140
|
+
r.stream.push(nil)
|
|
141
|
+
TnLoopUnref()
|
|
142
|
+
}
|
|
143
|
+
|
|
105
144
|
func (r *tnTestRun) emit(e *TnTestEvent) {
|
|
106
145
|
r.stream.push(e)
|
|
107
146
|
r.stream.emit(e.type_, e.data)
|
|
@@ -183,6 +222,9 @@ func (r *tnTestRun) fill() {
|
|
|
183
222
|
|
|
184
223
|
// Events of the file reporting now are relayed at once; later files' wait
|
|
185
224
|
func (r *tnTestRun) deliver(f *tnTestRunFile, e *TnTestEvent) {
|
|
225
|
+
if r.interrupted {
|
|
226
|
+
return
|
|
227
|
+
}
|
|
186
228
|
if r.reporting < len(r.files) && r.files[r.reporting] == f {
|
|
187
229
|
r.relay(f, e)
|
|
188
230
|
return
|
|
@@ -254,6 +296,8 @@ func (r *tnTestRun) startFile(f *tnTestRunFile) {
|
|
|
254
296
|
r.fileDone(f, 1, "")
|
|
255
297
|
return
|
|
256
298
|
}
|
|
299
|
+
f.started = true
|
|
300
|
+
f.cmd = cmd
|
|
257
301
|
r.emit(&TnTestEvent{type_: "test:dequeue", data: &TnTestEventData{name: f.path, file: f.path, line: 1, column: 1}})
|
|
258
302
|
var timer *time.Timer
|
|
259
303
|
if r.options != nil {
|
|
@@ -315,6 +359,10 @@ func (r *tnTestRun) startFile(f *tnTestRunFile) {
|
|
|
315
359
|
// A child exited: its file's summary (or a failure when it crashed), then
|
|
316
360
|
// the next files' held events
|
|
317
361
|
func (r *tnTestRun) fileDone(f *tnTestRunFile, code int, signal string) {
|
|
362
|
+
f.cmd = nil
|
|
363
|
+
if r.interrupted {
|
|
364
|
+
return
|
|
365
|
+
}
|
|
318
366
|
f.exitCode, f.signal = code, signal
|
|
319
367
|
r.running--
|
|
320
368
|
r.drain()
|
|
@@ -385,6 +433,13 @@ func (r *tnTestRun) closeFile(f *tnTestRunFile) {
|
|
|
385
433
|
}
|
|
386
434
|
|
|
387
435
|
func (r *tnTestRun) finish() {
|
|
436
|
+
if r.interrupted {
|
|
437
|
+
return
|
|
438
|
+
}
|
|
439
|
+
if r.onInterrupt != nil {
|
|
440
|
+
tnProcessEmitter.off("SIGINT", r.onInterrupt)
|
|
441
|
+
r.onInterrupt = nil
|
|
442
|
+
}
|
|
388
443
|
r.emit(&TnTestEvent{type_: "test:plan", data: &TnTestEventData{count: r.topLevel}})
|
|
389
444
|
c := r.counts
|
|
390
445
|
duration := math.Round(float64(time.Since(r.start).Nanoseconds())/1e2) / 1e4
|
package/bin/node/util.js
CHANGED
|
@@ -1340,18 +1340,21 @@ func TnCallbackify(fn interface{}) func(args ...interface{}) {
|
|
|
1340
1340
|
v, ok := result.Recv()
|
|
1341
1341
|
var reason interface{}
|
|
1342
1342
|
rejected := false
|
|
1343
|
+
var value interface{}
|
|
1343
1344
|
if !ok {
|
|
1344
|
-
|
|
1345
|
+
if resolved, hasVal := tnResolved.Load(result.Interface()); hasVal {
|
|
1346
|
+
value = resolved
|
|
1347
|
+
} else {
|
|
1348
|
+
reason, rejected = tnRejections.Load(result.Interface())
|
|
1349
|
+
}
|
|
1350
|
+
} else if v.IsValid() {
|
|
1351
|
+
value = v.Interface()
|
|
1345
1352
|
}
|
|
1346
1353
|
TnLoopPost(func() {
|
|
1347
1354
|
if rejected {
|
|
1348
1355
|
TnInvoke(cb, reason)
|
|
1349
1356
|
return
|
|
1350
1357
|
}
|
|
1351
|
-
var value interface{}
|
|
1352
|
-
if v.IsValid() {
|
|
1353
|
-
value = v.Interface()
|
|
1354
|
-
}
|
|
1355
1358
|
TnInvoke(cb, nil, value)
|
|
1356
1359
|
})
|
|
1357
1360
|
}()
|
package/bin/node/webassembly.js
CHANGED
|
@@ -956,7 +956,12 @@ func tnWasmResponseBytes[T any](r *TnResponse, out chan T, deliver func([]byte))
|
|
|
956
956
|
failure = rec
|
|
957
957
|
}
|
|
958
958
|
}()
|
|
959
|
-
|
|
959
|
+
v, reason, rejected := tnSettle(body)
|
|
960
|
+
if rejected {
|
|
961
|
+
failure = reason
|
|
962
|
+
return
|
|
963
|
+
}
|
|
964
|
+
data = v
|
|
960
965
|
}()
|
|
961
966
|
TnLoopPost(func() {
|
|
962
967
|
if failure != nil {
|
|
@@ -986,7 +991,12 @@ func tnWasmStreamingValue[T any](v interface{}, out chan T, deliver func([]byte)
|
|
|
986
991
|
TnLoopRef()
|
|
987
992
|
go func() {
|
|
988
993
|
defer TnLoopUnref()
|
|
989
|
-
|
|
994
|
+
val, reason, rejected := tnSettle(s)
|
|
995
|
+
if rejected {
|
|
996
|
+
TnReject(out, reason)
|
|
997
|
+
return
|
|
998
|
+
}
|
|
999
|
+
tnWasmStreamingValue(val, out, deliver)
|
|
990
1000
|
}()
|
|
991
1001
|
default:
|
|
992
1002
|
TnReject(out, tnWasmStreamingTypeError(v))
|
|
@@ -1005,7 +1015,12 @@ func tnWasmStreamingBytes[T any](src interface{}, out chan T, deliver func([]byt
|
|
|
1005
1015
|
TnLoopRef()
|
|
1006
1016
|
go func() {
|
|
1007
1017
|
defer TnLoopUnref()
|
|
1008
|
-
|
|
1018
|
+
val, reason, rejected := tnSettle(s)
|
|
1019
|
+
if rejected {
|
|
1020
|
+
TnReject(out, reason)
|
|
1021
|
+
return
|
|
1022
|
+
}
|
|
1023
|
+
tnWasmResponseBytes(val, out, deliver)
|
|
1009
1024
|
}()
|
|
1010
1025
|
case chan interface{}:
|
|
1011
1026
|
tnWasmStreamingValue(s, out, deliver)
|
|
@@ -1017,7 +1032,7 @@ func tnWasmStreamingBytes[T any](src interface{}, out chan T, deliver func([]byt
|
|
|
1017
1032
|
func TnWasmCompileStreaming(src interface{}) chan *TnWasmModule {
|
|
1018
1033
|
ch := make(chan *TnWasmModule, 1)
|
|
1019
1034
|
tnWasmStreamingBytes(src, ch, func(b []byte) {
|
|
1020
|
-
ch
|
|
1035
|
+
TnAsyncSend(ch, TnNewWasmModule(b))
|
|
1021
1036
|
})
|
|
1022
1037
|
return ch
|
|
1023
1038
|
}
|
|
@@ -1026,7 +1041,7 @@ func TnWasmInstantiateStreaming(src interface{}, importObject ...interface{}) ch
|
|
|
1026
1041
|
ch := make(chan *TnWasmInstantiated, 1)
|
|
1027
1042
|
tnWasmStreamingBytes(src, ch, func(b []byte) {
|
|
1028
1043
|
m := TnNewWasmModule(b)
|
|
1029
|
-
ch
|
|
1044
|
+
TnAsyncSend(ch, &TnWasmInstantiated{module: m, instance: TnNewWasmInstance(m, importObject...)})
|
|
1030
1045
|
})
|
|
1031
1046
|
return ch
|
|
1032
1047
|
}`;
|