Skip to content

Commit

Permalink
wip(e2e): adding e2e test for running neva cli not from module's root
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Apr 26, 2024
1 parent eaa0401 commit 771f9a4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/neva",
"cwd": "${workspaceFolder}",
"args": ["run", "examples/struct_selector"]
"cwd": "${workspaceFolder}/e2e/run_cli_not_from_module_root/foo",
"args": ["run", "bar"]
},
// === LSP ===
{
Expand Down
55 changes: 55 additions & 0 deletions e2e/run_cli_not_from_module_root/e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package test

// in this file we test files designed specifically for e2e.

import (
"os"
"os/exec"
"testing"

"github.com/stretchr/testify/require"
)

// Test that CLI will go from up to down and find module's manifest
func Test_UpperThanManifest(t *testing.T) {
// go one level up (and go back after test is finished)
wd, err := os.Getwd()
require.NoError(t, err)
defer os.Chdir(wd)
require.NoError(t, os.Chdir(".."))

cmd := exec.Command("neva", "run", "run_cli_not_from_module_root/foo/bar")

out, err := cmd.CombinedOutput()
require.NoError(t, err)
require.Equal(
t,
"42\n",
string(out),
)

require.Equal(t, 0, cmd.ProcessState.ExitCode())
}

// Test that CLI will go from down to up and find module's manifest
func Test_DownToManifest(t *testing.T) {
t.Skip() // FIXME https://github.com/nevalang/neva/issues/571

// go one level down (and go back after test is finished)
wd, err := os.Getwd()
require.NoError(t, err)
defer os.Chdir(wd)
require.NoError(t, os.Chdir("foo"))

cmd := exec.Command("neva", "run", "bar")

out, err := cmd.CombinedOutput()
require.NoError(t, err)
require.Equal(
t,
"42\n",
string(out),
)

require.Equal(t, 0, cmd.ProcessState.ExitCode())
}
4 changes: 4 additions & 0 deletions e2e/run_cli_not_from_module_root/foo/bar/main.neva
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
component Main(start) (stop) {
nodes { Println }
net { :start -> (42 -> println -> :stop) }
}
1 change: 1 addition & 0 deletions e2e/run_cli_not_from_module_root/neva.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
neva: 0.10.0

0 comments on commit 771f9a4

Please sign in to comment.