Skip to content

Commit

Permalink
Add integration test for "runtime in use" error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Nov 29, 2023
1 parent c032b40 commit 2d630e6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/integration/runtime_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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))
}

0 comments on commit 2d630e6

Please sign in to comment.