From b7cd50787a55ca98633dcb67ac2cf00b5a00bccd Mon Sep 17 00:00:00 2001 From: mdrakos Date: Wed, 2 Oct 2024 15:01:47 -0700 Subject: [PATCH 1/2] Pass port to service model --- .../scriptrun/test/integration/scriptrun_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/scriptrun/test/integration/scriptrun_test.go b/internal/scriptrun/test/integration/scriptrun_test.go index 506a7da279..191ec4236a 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(suite.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) From aed322e5d0a8ca51be8476b157ccb17d57d13d68 Mon Sep 17 00:00:00 2001 From: mdrakos Date: Thu, 3 Oct 2024 09:48:35 -0700 Subject: [PATCH 2/2] Pass in t --- internal/scriptrun/test/integration/scriptrun_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scriptrun/test/integration/scriptrun_test.go b/internal/scriptrun/test/integration/scriptrun_test.go index 191ec4236a..e7cc915608 100644 --- a/internal/scriptrun/test/integration/scriptrun_test.go +++ b/internal/scriptrun/test/integration/scriptrun_test.go @@ -90,7 +90,7 @@ scripts: func (suite *ScriptRunSuite) TestEnvIsSet() { suite.OnlyRunForTags(tagsuite.Scripts) t := suite.T() - ts := e2e.New(suite.T(), false) + ts := e2e.New(t, false) defer ts.Close() if runtime.GOOS == "windows" {