1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

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 <caarlos0@users.noreply.github.com>
This commit is contained in:
Radek Simko 2020-04-12 15:16:05 +01:00 committed by GitHub
parent cfa0cc2d2a
commit 5027d4bdfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)