diff --git a/internal/scriptrun/test/integration/scriptrun_test.go b/internal/scriptrun/test/integration/scriptrun_test.go index 506a7da279..e7cc915608 100644 --- a/internal/scriptrun/test/integration/scriptrun_test.go +++ b/internal/scriptrun/test/integration/scriptrun_test.go @@ -9,8 +9,11 @@ import ( "testing" "github.com/ActiveState/cli/internal/analytics/client/blackhole" + "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/scriptrun" + "github.com/ActiveState/cli/internal/svcctl" + "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/suite" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" "github.com/kami-zh/go-capturer" @@ -87,6 +90,8 @@ scripts: func (suite *ScriptRunSuite) TestEnvIsSet() { suite.OnlyRunForTags(tagsuite.Scripts) t := suite.T() + ts := e2e.New(t, false) + defer ts.Close() if runtime.GOOS == "windows" { // For some reason this test hangs on Windows when ran via CI. I cannot reproduce the issue when manually invoking the @@ -119,8 +124,17 @@ func (suite *ScriptRunSuite) TestEnvIsSet() { cfg.Set(constants.AsyncRuntimeConfig, true) + ipcClient := svcctl.NewDefaultIPCClient() + var svcPort string + + svcExec, err := installation.ServiceExecFromDir(ts.Dirs.Bin) + suite.Require().NoError(err, errs.JoinMessage(err)) + + svcPort, err = svcctl.EnsureExecStartedAndLocateHTTP(ipcClient, svcExec, "from test", nil) + suite.Require().NoError(err, errs.JoinMessage(err)) + out := capturer.CaptureOutput(func() { - scriptRun := scriptrun.New(primer.New(auth, outputhelper.NewCatcher(), subshell.New(cfg), proj, cfg, blackhole.New(), model.NewSvcModel(""))) + scriptRun := scriptrun.New(primer.New(auth, outputhelper.NewCatcher(), subshell.New(cfg), proj, cfg, blackhole.New(), model.NewSvcModel(svcPort))) script, err := proj.ScriptByName("run") require.NoError(t, err, "Error: "+errs.JoinMessage(err)) err = scriptRun.Run(script, nil)