This repository was archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
CIRRUS_CLONE_DIR #130
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c28f440
Support $CIRRUS_CLONE_DIR
fkorotkov 9d91b5e
Better testing
fkorotkov 5a0e33b
Override TMPDIR in tests
fkorotkov 36f116a
No need to override TMPDIR in config
fkorotkov 7b8233f
Fixed ignoring on Windows
fkorotkov d30d90e
Ignore on FreeBSD
fkorotkov df16aa9
Moved tests
fkorotkov e5fb2d1
Respect precreated
fkorotkov 92d1ac2
Run TestPopulateCloneAndWorkingDirEnvironmentVariables only on Linux …
fkorotkov f82d56d
Renamed executors
fkorotkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
// +build !windows !freebsd | ||
|
||
package executor | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestPopulateCloneAndWorkingDirEnvironmentVariables(t *testing.T) { | ||
tmpDirToRestore := os.Getenv("TMPDIR") | ||
_ = os.Setenv("TMPDIR", "/tmp") | ||
e := &Executor{} | ||
ePreCreate := &Executor{} | ||
ePreCreate.SetPreCreatedWorkingDir("/tmp/precreated-build") | ||
edigaryev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
examples := []struct { | ||
Executor *Executor | ||
Description string | ||
Given, Expected map[string]string | ||
}{ | ||
{ | ||
e, | ||
"empty", | ||
map[string]string{}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/cirrus-ci-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR", | ||
}, | ||
}, | ||
{ | ||
ePreCreate, | ||
"empty (precreated)", | ||
map[string]string{}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/precreated-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR", | ||
}, | ||
}, | ||
{ | ||
e, | ||
"only working", | ||
map[string]string{ | ||
"CIRRUS_WORKING_DIR": "/tmp/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "$CIRRUS_WORKING_DIR", | ||
"CIRRUS_WORKING_DIR": "/tmp/foo", | ||
}, | ||
}, | ||
{ | ||
ePreCreate, | ||
"only working (precreated)", | ||
map[string]string{ | ||
"CIRRUS_WORKING_DIR": "/tmp/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/precreated-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR", | ||
}, | ||
}, | ||
{ | ||
e, | ||
"only working (monorepo)", | ||
map[string]string{ | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/cirrus-ci-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/foo", | ||
}, | ||
}, | ||
{ | ||
ePreCreate, | ||
"only working (monorepo + precreated)", | ||
map[string]string{ | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/precreated-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/foo", | ||
}, | ||
}, | ||
{ | ||
e, | ||
"only clone", | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR", | ||
}, | ||
}, | ||
{ | ||
ePreCreate, | ||
"only clone (precreated)", | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/precreated-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR", | ||
}, | ||
}, | ||
{ | ||
e, | ||
"both", | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
"CIRRUS_WORKING_DIR": "/tmp/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
"CIRRUS_WORKING_DIR": "/tmp/foo", | ||
}, | ||
}, | ||
{ | ||
ePreCreate, | ||
"both (precreated)", | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
"CIRRUS_WORKING_DIR": "/tmp/foo", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/precreated-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR", | ||
}, | ||
}, | ||
{ | ||
e, | ||
"both (monorepo)", | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/bar", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/bar", | ||
}, | ||
}, | ||
{ | ||
ePreCreate, | ||
"both (monorepo + precreated)", | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/foo", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/bar", | ||
}, | ||
map[string]string{ | ||
"CIRRUS_CLONE_DIR": "/tmp/precreated-build", | ||
"CIRRUS_WORKING_DIR": "$CIRRUS_CLONE_DIR/bar", | ||
}, | ||
}, | ||
} | ||
|
||
for _, example := range examples { | ||
t.Run(example.Description, func(t *testing.T) { | ||
require.Equal(t, example.Expected, example.Executor.PopulateCloneAndWorkingDirEnvironmentVariables(example.Given)) | ||
}) | ||
} | ||
_ = os.Setenv("TMPDIR", tmpDirToRestore) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the
$CIRRUS_CLONE_DIR
variable occurrence in the middle ofCIRRUS_WORKING_DIR
should be considered as theCIRRUS_WORKING_DIR
won't be rooted inCIRRUS_CLONE_DIR
this way.See #129 for a more strict check.