Skip to content

Commit

Permalink
e2e: Test all entrypoints.
Browse files Browse the repository at this point in the history
This fixes #1658.
  • Loading branch information
xiaq committed Dec 31, 2024
1 parent 6f26db2 commit 8b43b8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,34 @@ import (
var transcripts embed.FS

const buildScript = `
# Using "-o $workdir/" instead of "-o $workdir/elvish" gets us the correct file
# extension on Windows
go build (if (not-eq $E:GOCOVERDIR '') { put -cover }) -o $workdir/ src.elv.sh/cmd/elvish
# This script relies on the fact that go tests are always run in the package's
# directory; it should be run before changing directory.
#
# Note: Using "-o $workdir/" instead of "-o $workdir/elvish" here gets us the
# correct file extension on Windows
go build (if (not-eq $E:GOCOVERDIR '') { put -cover }) -o $workdir/ src.elv.sh/$entrypoint
`

func TestTranscripts(t *testing.T) {
func TestTranscripts_Default(t *testing.T) {
testTranscripts(t, "cmd/elvish")
}

func TestTranscripts_NoDaemon(t *testing.T) {
testTranscripts(t, "cmd/nodaemon/elvish")
}

func TestTranscripts_WithPprof(t *testing.T) {
testTranscripts(t, "cmd/withpprof/elvish")
}

func testTranscripts(t *testing.T, entrypoint string) {
workdir := t.TempDir()
err := eval.NewEvaler().Eval(
parse.Source{Name: "[build]", Code: buildScript},
eval.EvalCfg{
Global: eval.BuildNs().AddVars(map[string]vars.Var{
"workdir": vars.NewReadOnly(workdir),
"entrypoint": vars.NewReadOnly(entrypoint),
"workdir": vars.NewReadOnly(workdir),
}).Ns()})
if err != nil {
t.Fatal(err)
Expand Down
File renamed without changes.

0 comments on commit 8b43b8e

Please sign in to comment.