Skip to content

Commit 1c7e526

Browse files
authored
Merge pull request ActiveState#3548 from ActiveState/DX-3116
Fix path ordering
2 parents c3b9e85 + 97813a8 commit 1c7e526

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

internal/runners/exec/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/ActiveState/cli/internal/output"
2525
"github.com/ActiveState/cli/internal/primer"
2626
"github.com/ActiveState/cli/internal/runbits/rationalize"
27-
"github.com/ActiveState/cli/internal/runbits/runtime"
27+
runtime_runbit "github.com/ActiveState/cli/internal/runbits/runtime"
2828
"github.com/ActiveState/cli/internal/runbits/runtime/trigger"
2929
"github.com/ActiveState/cli/internal/subshell"
3030
"github.com/ActiveState/cli/internal/virtualenvironment"

pkg/runtime/internal/envdef/collection.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package envdef
22

33
import (
4+
"os"
45
"path/filepath"
6+
"runtime"
57
"sync"
68

79
"github.com/ActiveState/cli/internal/errs"
@@ -63,5 +65,29 @@ func (c *Collection) Environment(installPath string, inherit bool) (map[string]s
6365
}
6466
}
6567
constants := NewConstants(installPath)
66-
return result.ExpandVariables(constants).GetEnv(inherit), nil
68+
env := result.ExpandVariables(constants).GetEnv(inherit)
69+
promotePath(env)
70+
return env, nil
71+
}
72+
73+
// promotPath is a temporary fix to ensure that the PATH is interpreted correctly on Windows
74+
// Should be properly addressed by https://activestatef.atlassian.net/browse/DX-3030
75+
func promotePath(env map[string]string) {
76+
if runtime.GOOS != "windows" {
77+
return
78+
}
79+
80+
PATH, exists := env["PATH"]
81+
if !exists {
82+
return
83+
}
84+
85+
// If Path exists, prepend PATH values to it
86+
Path, pathExists := env["Path"]
87+
if !pathExists {
88+
return
89+
}
90+
91+
env["Path"] = PATH + string(os.PathListSeparator) + Path
92+
delete(env, "PATH")
6793
}

test/integration/exec_int_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ import (
88
"runtime"
99
"strings"
1010
"testing"
11-
"time"
1211

1312
"github.com/ActiveState/cli/internal/constants"
1413
"github.com/ActiveState/cli/internal/environment"
1514
"github.com/ActiveState/cli/internal/fileutils"
1615
"github.com/ActiveState/cli/internal/testhelpers/e2e"
1716
"github.com/ActiveState/cli/internal/testhelpers/suite"
1817
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
19-
"github.com/ActiveState/termtest"
2018
)
2119

2220
type ExecIntegrationTestSuite struct {
@@ -176,7 +174,7 @@ func (suite *ExecIntegrationTestSuite) TestExeBatArguments() {
176174
inputs := []string{"a<b", "b>a", "hello world", "&whoami", "imnot|apipe", "%NotAppData%", "^NotEscaped", "(NotAGroup)"}
177175
outputs := `"` + strings.Join(inputs, `" "`) + `"`
178176
cp = ts.SpawnWithOpts(e2e.OptArgs(append([]string{"exec", reportBat, "--"}, inputs...)...))
179-
cp.Expect(outputs, termtest.OptExpectTimeout(5*time.Second))
177+
cp.Expect(outputs, e2e.RuntimeBuildSourcingTimeoutOpt)
180178
cp.ExpectExitCode(0)
181179
}
182180

0 commit comments

Comments
 (0)