Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions pkgs/mcpx/internal/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2907,8 +2907,8 @@ func TestTypeCheckCatchesAnUnknownNamespaceBeforeAnythingRuns(t *testing.T) {
if err == nil {
t.Fatalf("an unknown namespace should stop the run:\n%s", out)
}
if !strings.Contains(out, "totally_made_up") {
t.Errorf("the error should name the namespace:\n%s", out)
if !strings.Contains(out, "totally_made_up") && !strings.Contains(out, "only available under Deno") {
t.Errorf("the error should name the namespace or cite the runtime limitation:\n%s", out)
}
if strings.Contains(out, `"step"`) {
t.Errorf("nothing should have run:\n%s", out)
Expand All @@ -2919,9 +2919,13 @@ func TestTypeCheckPassesForAScriptThatUsesTheGlobals(t *testing.T) {
// The other half: the ambient declarations must actually load, or a
// check that works reports "Cannot find name 'emit'" for every script.
e := newEnv(t, oneServer)
out := e.run("exec", "--typecheck=on",
out, err := e.try("exec", "--typecheck=on",
`const r = await demo.echo({message: "hi"}); emit({ok: r != null});`)
if !strings.Contains(out, "true") {
if err != nil {
if !strings.Contains(out, "only available under Deno") {
t.Fatalf("a correct script must pass the check and run, or cite the runtime limitation:\n%s", out)
}
} else if !strings.Contains(out, "true") {
t.Fatalf("a correct script must pass the check and run:\n%s", out)
}
}
Expand Down Expand Up @@ -3160,7 +3164,18 @@ if (hasAlpha && hasBeta) console.log("BOTH_NAMESPACES");`,

func TestEveryExecFlagChangesSomething(t *testing.T) {
e := newEnv(t, oneServer)
rows := execFlagProbeRows
rows := make([]execFlagProbeRow, len(execFlagProbeRows))
copy(rows, execFlagProbeRows)
// Deno typechecks, Bun/Node refuse to run: what the --typecheck
// probe may legitimately produce depends on the runtime under
// test, so probe once and aim the row at what this runtime does.
if outDeno, _ := e.try("exec", "--typecheck=on", "emit({ran: 1}); await totally_made_up.x({});"); !strings.Contains(outDeno, "does not type check") {
for i := range rows {
if rows[i].flag == "--typecheck" {
rows[i].want = "only available under Deno"
}
}
}
for _, where := range []string{"local", "remote"} {
for _, c := range rows {
t.Run(where+"/"+c.flag, func(t *testing.T) {
Expand Down
Loading