From afa4722287ad03cea5f65294db23a6f0d2db1e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=A4umer?= Date: Mon, 25 Feb 2019 11:36:42 +0100 Subject: [PATCH] Add integration tests --- commander.yaml | 5 +++++ examples/commander.yaml | 8 ++++---- pkg/runtime/runtime.go | 11 ++--------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/commander.yaml b/commander.yaml index c7f85e25..8b7f6464 100644 --- a/commander.yaml +++ b/commander.yaml @@ -4,4 +4,9 @@ tests: exit-code: 3 it should display help: command: ./commander + exit-code: 0 + it should execute tests: + command: ./commander test ./examples/commander.yaml + stdout: >- + ✓ it should fail exit-code: 0 \ No newline at end of file diff --git a/examples/commander.yaml b/examples/commander.yaml index a18fd881..7ca4ef0c 100644 --- a/examples/commander.yaml +++ b/examples/commander.yaml @@ -1,5 +1,5 @@ tests: - "it should print hello world": - command: "echo hello world" - stdout: hello world - exit-code: 0 \ No newline at end of file + it should fail: + command: /bin/bash invalid + stderr: "/bin/bash: invalid: No such file or directory" + exit-code: 127 \ No newline at end of file diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index f25ca20b..614ae307 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -74,21 +74,14 @@ func runTest(test commander.TestCase, results chan<- commander.TestCase) { } func compile(command string) *Command { - parts := strings.Split(command, " ") - executable := parts[0] - - splitArgs := append(parts[:0], parts[1:]...) - args := strings.Join(splitArgs, " ") - return &Command{ - cmd: executable, - args: args, + cmd: command, } } // Execute executes a command on the system func (c *Command) Execute() error { - cmd := exec.Command(c.cmd, c.args) + cmd := exec.Command("sh", "-c", c.cmd) env := os.Environ() cmd.Env = env