From 696656b167850ceaf43c6160ea76f96c6e19c332 Mon Sep 17 00:00:00 2001 From: Pablo Chacin Date: Wed, 7 Dec 2022 10:57:28 +0100 Subject: [PATCH 1/3] Do not use Linux paths in unit tests Signed-off-by: Pablo Chacin --- pkg/utils/process/fake_test.go | 8 ++++---- pkg/utils/process/process_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/utils/process/fake_test.go b/pkg/utils/process/fake_test.go index 975ab4c1..07358377 100644 --- a/pkg/utils/process/fake_test.go +++ b/pkg/utils/process/fake_test.go @@ -24,13 +24,13 @@ func Test_FakeExecutor(t *testing.T) { }, { title: "command without arguments", - cmdLine: "/bin/true", + cmdLine: "true", out: []byte{}, err: nil, }, { title: "command returning error", - cmdLine: "/bin/false", + cmdLine: "false", out: []byte{}, err: fmt.Errorf("command exited with rc 1"), }, @@ -157,13 +157,13 @@ func Test_Callbacks(t *testing.T) { }, { title: "command without arguments", - cmdLine: "/bin/true", + cmdLine: "true", out: []byte{}, err: nil, }, { title: "command returning error", - cmdLine: "/bin/false", + cmdLine: "false", out: []byte{}, err: fmt.Errorf("command exited with rc 1"), }, diff --git a/pkg/utils/process/process_test.go b/pkg/utils/process/process_test.go index b91e4a9c..283e7d72 100644 --- a/pkg/utils/process/process_test.go +++ b/pkg/utils/process/process_test.go @@ -23,26 +23,26 @@ func Test_Exec(t *testing.T) { }, { title: "return stderr", - cmd: "/bin/bash", + cmd: "sh", args: []string{"-c", "echo -n 'hello world' 2>&1"}, expectError: false, expectOutput: "hello world", }, { title: "do not return output", - cmd: "/bin/true", + cmd: "true", expectError: false, expectOutput: "", }, { title: "command return error code", - cmd: "/bin/false", + cmd: "false", expectError: true, expectOutput: "", }, { title: "return error code and stderr", - cmd: "/bin/bash", + cmd: "sh", args: []string{"-c", "echo -n 'hello world' 2>&1; kill -KILL $$"}, expectError: true, expectOutput: "hello world", From c293f6a81a7268f5fed6355f8490552502fee7c8 Mon Sep 17 00:00:00 2001 From: Pablo Chacin Date: Wed, 7 Dec 2022 10:58:01 +0100 Subject: [PATCH 2/3] Run PR jobs in multiple platforms Signed-off-by: Pablo Chacin --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b3db18e..517b0fdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,10 @@ on: jobs: build-with-xk6: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] steps: - name: Checkout code uses: actions/checkout@v3 @@ -26,7 +29,10 @@ jobs: xk6 build --with $(go list -m)=. run-unit-tests: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] steps: - name: Checkout code uses: actions/checkout@v3 From 4c4dd1e09d4ec75afdb8e76339b194582c1eab8e Mon Sep 17 00:00:00 2001 From: Pablo Chacin Date: Wed, 7 Dec 2022 11:40:01 +0100 Subject: [PATCH 3/3] Remove -n option from echo commands Signed-off-by: Pablo Chacin --- pkg/utils/process/process_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/utils/process/process_test.go b/pkg/utils/process/process_test.go index 283e7d72..7bc81add 100644 --- a/pkg/utils/process/process_test.go +++ b/pkg/utils/process/process_test.go @@ -24,9 +24,9 @@ func Test_Exec(t *testing.T) { { title: "return stderr", cmd: "sh", - args: []string{"-c", "echo -n 'hello world' 2>&1"}, + args: []string{"-c", "echo hello world 2>&1"}, expectError: false, - expectOutput: "hello world", + expectOutput: "hello world\n", }, { title: "do not return output", @@ -43,9 +43,9 @@ func Test_Exec(t *testing.T) { { title: "return error code and stderr", cmd: "sh", - args: []string{"-c", "echo -n 'hello world' 2>&1; kill -KILL $$"}, + args: []string{"-c", "echo hello world 2>&1; kill -KILL $$"}, expectError: true, - expectOutput: "hello world", + expectOutput: "hello world\n", }, }