@@ -4,19 +4,22 @@ import (
44 "os"
55 "path/filepath"
66 "runtime"
7+ "strings"
78 "testing"
89 "time"
910
11+ "github.com/ActiveState/termtest"
12+
1013 "github.com/ActiveState/cli/internal/constants"
1114 "github.com/ActiveState/cli/internal/environment"
15+ "github.com/ActiveState/cli/internal/fileutils"
1216 "github.com/ActiveState/cli/internal/osutils"
1317 "github.com/ActiveState/cli/internal/svcctl"
1418 "github.com/ActiveState/cli/internal/testhelpers/e2e"
1519 "github.com/ActiveState/cli/internal/testhelpers/suite"
1620 "github.com/ActiveState/cli/internal/testhelpers/tagsuite"
1721 "github.com/ActiveState/cli/pkg/platform/runtime/executors"
1822 "github.com/ActiveState/cli/pkg/platform/runtime/target"
19- "github.com/ActiveState/termtest"
2023)
2124
2225type ExecutorIntegrationTestSuite struct {
@@ -109,8 +112,8 @@ func (suite *ExecutorIntegrationTestSuite) TestExecutorBatArguments() {
109112
110113 root := environment .GetRootPathUnsafe ()
111114 executorsPath := filepath .Join (ts .Dirs .Work , "executors" )
112- srcBatFile := filepath .Join (root , "test" , "integration" , "testdata" , "batarguments" , "batargtest.bat" )
113- targetExeFile := filepath .Join (executorsPath , "batargtest .exe" )
115+ srcExes := fileutils . ListFilesUnsafe ( filepath .Join (root , "test" , "integration" , "testdata" , "batarguments" ) )
116+ reportExe := filepath .Join (executorsPath , "report .exe" )
114117
115118 t := target .NewCustomTarget ("ActiveState-CLI" , "test" , constants .ValidZeroUUID , "" , target .TriggerExecutor )
116119 executors := executors .New (executorsPath )
@@ -119,17 +122,28 @@ func (suite *ExecutorIntegrationTestSuite) TestExecutorBatArguments() {
119122 svcctl .NewIPCSockPathFromGlobals ().String (),
120123 t ,
121124 osutils .EnvSliceToMap (ts .Env ),
122- [] string { srcBatFile } ,
125+ srcExes ,
123126 )
124127 suite .Require ().NoError (err )
125- suite .Require ().FileExists (targetExeFile )
128+ suite .Require ().FileExists (reportExe )
126129
127130 // Force override ACTIVESTATE_CI to false, because communicating with the svc will fail, and if this is true
128131 // the executor will interrupt.
129132 // For this test we don't care about the svc communication.
130133 env := e2e .OptAppendEnv ("ACTIVESTATE_CI=false" )
131134
132- cp := ts .SpawnCmdWithOpts (targetExeFile , e2e .OptArgs ("a<b" , "hello world" ), env )
133- cp .Expect (`"a<b" "hello world"` , termtest .OptExpectTimeout (5 * time .Second ))
135+ inputs := []string {"a<b" , "b>a" , "hello world" , "&whoami" , "imnot|apipe" , "%NotAppData%" , "^NotEscaped" , "(NotAGroup)" }
136+ outputs := `"` + strings .Join (inputs , `" "` ) + `"`
137+ cp := ts .SpawnCmdWithOpts (reportExe , e2e .OptArgs (inputs ... ), env )
138+ cp .Expect (outputs , termtest .OptExpectTimeout (5 * time .Second ))
139+ cp .ExpectExitCode (0 )
140+
141+ cp = ts .SpawnCmdWithOpts (reportExe , e2e .OptArgs ("&whoami" ), env )
142+ cp .Expect (`"&whoami"` , termtest .OptExpectTimeout (5 * time .Second ))
143+ cp .ExpectExitCode (0 )
144+
145+ // Ensure regular arguments aren't quoted
146+ cp = ts .SpawnCmdWithOpts (reportExe , e2e .OptArgs ("ImNormal" , "I'm Special" , "ImAlsoNormal" ), env )
147+ cp .Expect (`ImNormal "I'm Special" ImAlsoNormal` , termtest .OptExpectTimeout (5 * time .Second ))
134148 cp .ExpectExitCode (0 )
135149}
0 commit comments