From 5027d4bdfedbf4ff296feaec624c66b9c9d3932d Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sun, 12 Apr 2020 15:16:05 +0100 Subject: [PATCH] test: Allow tests to run in parallel without failing (#1429) All tests share the same environment (hence variable namespace too) and setting & reading the same variables has lead to race conditions which are being fixed by using different variables in each test. Co-authored-by: Carlos Alexandro Becker --- internal/pipe/build/build_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/pipe/build/build_test.go b/internal/pipe/build/build_test.go index d471c30e1..d8579859e 100644 --- a/internal/pipe/build/build_test.go +++ b/internal/pipe/build/build_test.go @@ -201,13 +201,13 @@ func TestDefaultNoBuilds(t *testing.T) { } func TestDefaultExpandEnv(t *testing.T) { - assert.NoError(t, os.Setenv("BAR", "FOOBAR")) + assert.NoError(t, os.Setenv("XBAR", "FOOBAR")) var ctx = &context.Context{ Config: config.Project{ Builds: []config.Build{ { Env: []string{ - "FOO=bar_$BAR", + "XFOO=bar_$XBAR", }, }, }, @@ -215,7 +215,7 @@ func TestDefaultExpandEnv(t *testing.T) { } assert.NoError(t, Pipe{}.Default(ctx)) var env = ctx.Config.Builds[0].Env[0] - assert.Equal(t, "FOO=bar_FOOBAR", env) + assert.Equal(t, "XFOO=bar_FOOBAR", env) } func TestDefaultEmptyBuild(t *testing.T) { @@ -426,7 +426,6 @@ func TestHookEnvs(t *testing.T) { }) t.Run("env inside shell", func(t *testing.T) { - t.Skip("this fails on travis for some reason") var shell = `#!/bin/sh -e touch "$BAR"` err := ioutil.WriteFile(filepath.Join(tmp, "test.sh"), []byte(shell), 0750)