mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
feat(testrun): bundle the goja runtime entry so the verifier runs the shared picker
This commit is contained in:
1 parent
45366ddde5
commit
76c68b84ac
1 file changed
+20
-5
@@ -60,8 +60,13 @@ func Execute(ctx context.Context, options Options, stdout io.Writer) error {
|
|||||||
"SANDERLING_TEST_OTP": os.Getenv("SANDERLING_TEST_OTP"),
|
"SANDERLING_TEST_OTP": os.Getenv("SANDERLING_TEST_OTP"),
|
||||||
"SANDERLING_SEED": strconv.FormatInt(seed, 10),
|
"SANDERLING_SEED": strconv.FormatInt(seed, 10),
|
||||||
}
|
}
|
||||||
|
gojaRuntimePath := resolveGojaRuntimePath(specAPIPath, options.Spec)
|
||||||
|
if gojaRuntimePath == "" {
|
||||||
|
return fmt.Errorf("goja-runtime.ts not found near %s; checkout pkg/spec or set @sanderling/spec alias", options.Spec)
|
||||||
|
}
|
||||||
bundle, err := bundler.Bundle(bundler.Options{
|
bundle, err := bundler.Bundle(bundler.Options{
|
||||||
EntryFile: options.Spec,
|
EntryFile: options.Spec,
|
||||||
|
RuntimeFile: gojaRuntimePath,
|
||||||
Defines: defines,
|
Defines: defines,
|
||||||
Aliases: aliases,
|
Aliases: aliases,
|
||||||
})
|
})
|
||||||
@@ -183,12 +188,22 @@ func resolveSeed(configured int64) int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resolveWebRuntimePath returns the path to pkg/spec/src/web-runtime.ts.
|
// resolveWebRuntimePath returns the path to pkg/spec/src/web-runtime.ts.
|
||||||
// Tries the spec-API checkout first (so monorepo development works without
|
|
||||||
// publishing the package), then falls back to a sibling of the resolved
|
|
||||||
// @sanderling/spec entry, and finally to a node_modules path.
|
|
||||||
func resolveWebRuntimePath(specAPIPath, userSpecPath string) string {
|
func resolveWebRuntimePath(specAPIPath, userSpecPath string) string {
|
||||||
|
return resolveRuntimeSibling(specAPIPath, userSpecPath, "web-runtime.ts")
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolveGojaRuntimePath returns the path to pkg/spec/src/goja-runtime.ts, the
|
||||||
|
// native verifier's runtime entry that installs __sanderlingNextAction__.
|
||||||
|
func resolveGojaRuntimePath(specAPIPath, userSpecPath string) string {
|
||||||
|
return resolveRuntimeSibling(specAPIPath, userSpecPath, "goja-runtime.ts")
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolveRuntimeSibling finds a runtime-entry file that sits beside the spec-API
|
||||||
|
// index.ts. Tries the spec-API checkout first (so monorepo development works
|
||||||
|
// without publishing the package), then falls back to a node_modules path.
|
||||||
|
func resolveRuntimeSibling(specAPIPath, userSpecPath, filename string) string {
|
||||||
if specAPIPath != "" {
|
if specAPIPath != "" {
|
||||||
candidate := filepath.Join(filepath.Dir(specAPIPath), "web-runtime.ts")
|
candidate := filepath.Join(filepath.Dir(specAPIPath), filename)
|
||||||
if _, err := os.Stat(candidate); err == nil {
|
if _, err := os.Stat(candidate); err == nil {
|
||||||
return candidate
|
return candidate
|
||||||
}
|
}
|
||||||
@@ -196,7 +211,7 @@ func resolveWebRuntimePath(specAPIPath, userSpecPath string) string {
|
|||||||
if absoluteSpec, err := filepath.Abs(userSpecPath); err == nil {
|
if absoluteSpec, err := filepath.Abs(userSpecPath); err == nil {
|
||||||
directory := filepath.Dir(absoluteSpec)
|
directory := filepath.Dir(absoluteSpec)
|
||||||
for {
|
for {
|
||||||
candidate := filepath.Join(directory, "node_modules", "@sanderling", "spec", "src", "web-runtime.ts")
|
candidate := filepath.Join(directory, "node_modules", "@sanderling", "spec", "src", filename)
|
||||||
if _, err := os.Stat(candidate); err == nil {
|
if _, err := os.Stat(candidate); err == nil {
|
||||||
return candidate
|
return candidate
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user