From 2d630e6e92794a30bf074f6859c0e4bf0644d86b Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 29 Nov 2023 15:19:58 -0500 Subject: [PATCH] Add integration test for "runtime in use" error. --- test/integration/runtime_int_test.go | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/integration/runtime_int_test.go b/test/integration/runtime_int_test.go index c7ec78a267..afb5b8f179 100644 --- a/test/integration/runtime_int_test.go +++ b/test/integration/runtime_int_test.go @@ -11,6 +11,7 @@ import ( "github.com/ActiveState/cli/internal/testhelpers/tagsuite" "github.com/ActiveState/cli/pkg/platform/runtime/setup" "github.com/ActiveState/cli/pkg/platform/runtime/target" + "github.com/ActiveState/termtest" "github.com/stretchr/testify/suite" ) @@ -111,6 +112,37 @@ func (suite *RuntimeIntegrationTestSuite) TestInterruptSetup() { cp.ExpectExitCode(0) } +func (suite *RuntimeIntegrationTestSuite) TestInUse() { + suite.OnlyRunForTags(tagsuite.Critical) + ts := e2e.New(suite.T(), false) + defer ts.Close() + + cp := ts.Spawn("checkout", "ActiveState-CLI/Perl-5.32", ".") + cp.Expect("Skipping runtime setup") + cp.ExpectExitCode(0) + + cp = ts.SpawnWithOpts( + e2e.OptArgs("shell"), + e2e.OptAppendEnv(constants.DisableRuntime+"=false"), + ) + cp.Expect("Activated", e2e.RuntimeSourcingTimeoutOpt) + cp.SendLine("perl") + time.Sleep(1 * time.Second) // allow time for perl to start up + + cp2 := ts.SpawnWithOpts( + e2e.OptArgs("install", "DateTime"), + e2e.OptAppendEnv(constants.DisableRuntime+"=false"), + ) + cp2.Expect("currently in use", termtest.OptExpectTimeout(15*time.Second)) + cp2.Expect("perl") + cp2.ExpectNotExitCode(0) + ts.IgnoreLogErrors() + + cp.SendCtrlC() + cp.SendLine("exit") + cp.ExpectExit() // code can vary depending on shell; just assert process finished +} + func TestRuntimeIntegrationTestSuite(t *testing.T) { suite.Run(t, new(RuntimeIntegrationTestSuite)) }