Skip to content

Commit

Permalink
Updated comment for clarity and added integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Oct 23, 2024
1 parent 7653324 commit 26bd059
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/runtime/internal/envdef/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,10 @@ func (ed *EnvironmentDefinition) getEnvBasedOn(envLookup map[string]string) (map
if len(ev.Values) > 0 {
res[pev.Name] = pev.ValueString()
if pev.Name != osName {
// On Windows, delete the case-insensitive version. Our case-sensitive version has already
// processed the value of the case-insensitive version.
// On Windows, delete the redundant (case-insensitive) version that our case-sensitive
// version could conflict with. (Our version has already processed the value of the
// redundant version.)
// For example, delete "Path" while preserving our "PATH".
delete(res, osName)
}
}
Expand Down
27 changes: 27 additions & 0 deletions test/integration/exec_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,33 @@ func (suite *ExecIntegrationTestSuite) TestExeBatArguments() {
cp.ExpectExitCode(0)
}

func (suite *ExecIntegrationTestSuite) TestExec_PATH_and_Path_on_Windows() {
suite.OnlyRunForTags(tagsuite.Exec)

if runtime.GOOS != "windows" {
suite.T().Skip("This test is only for windows")
}

ts := e2e.New(suite.T(), false)
defer ts.Close()

cp := ts.Spawn("checkout", "ActiveState-CLI/small-python", ".")
cp.Expect("Checked out")
cp.ExpectExitCode(0)

cp = ts.Spawn("exec", "where", "python3")
cp.Expect(os.TempDir()) // from runtime's defined PATH
cp.ExpectExitCode(0)

cp = ts.Spawn("exec", "where", "notepad")
cp.Expect("notepad.exe") // from OS-defined default Path
cp.ExpectExitCode(0)

cp = ts.Spawn("exec", "where", "does-not-exist")
cp.Expect("not found") // neither on PATH or Path
cp.ExpectNotExitCode(0)
}

func TestExecIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(ExecIntegrationTestSuite))
}

0 comments on commit 26bd059

Please sign in to comment.