1616
1717package com .goide .runconfig .testing ;
1818
19- import com .goide .GoEnvironmentUtil ;
2019import com .goide .psi .GoFile ;
2120import com .goide .psi .GoFunctionDeclaration ;
2221import com .goide .runconfig .GoRunningState ;
22+ import com .goide .util .GoExecutor ;
2323import com .intellij .execution .DefaultExecutionResult ;
2424import com .intellij .execution .ExecutionException ;
2525import com .intellij .execution .ExecutionResult ;
2626import com .intellij .execution .Executor ;
27- import com .intellij .execution .configurations .GeneralCommandLine ;
2827import com .intellij .execution .filters .TextConsoleBuilder ;
2928import com .intellij .execution .filters .TextConsoleBuilderFactory ;
3029import com .intellij .execution .process .ProcessHandler ;
@@ -67,34 +66,24 @@ public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunne
6766 return executionResult ;
6867 }
6968
70- @ NotNull
7169 @ Override
72- protected GeneralCommandLine getCommand (String sdkHomePath ) throws ExecutionException {
73- String executable = GoEnvironmentUtil .getExecutableForSdk (sdkHomePath ).getAbsolutePath ();
74- GeneralCommandLine runTests = new GeneralCommandLine ();
75- runTests .setExePath (executable );
76- runTests .addParameters ("test" , "-v" );
77- fillCommandLineWithParameters (runTests );
78- return runTests ;
79- }
80-
81- private void fillCommandLineWithParameters (@ NotNull GeneralCommandLine commandLine ) throws ExecutionException {
82- commandLine .withWorkDirectory (myConfiguration .getWorkingDirectory ());
70+ protected GoExecutor patchExecutor (@ NotNull GoExecutor executor ) throws ExecutionException {
71+ executor .addParameters ("test" , "-v" );
8372 switch (myConfiguration .getKind ()) {
8473 case DIRECTORY :
8574 String relativePath = FileUtil .getRelativePath (myConfiguration .getWorkingDirectory (),
8675 myConfiguration .getDirectoryPath (),
8776 File .separatorChar );
8877 if (relativePath != null ) {
89- commandLine . addParameter (relativePath + "/..." );
78+ executor . addParameters (relativePath + "/..." );
9079 }
9180 else {
92- commandLine . addParameter ("./..." );
93- commandLine .withWorkDirectory (myConfiguration .getDirectoryPath ());
81+ executor . addParameters ("./..." );
82+ executor .withWorkDirectory (myConfiguration .getDirectoryPath ());
9483 }
9584 break ;
9685 case PACKAGE :
97- commandLine . addParameter (myConfiguration .getPackage ());
86+ executor . addParameters (myConfiguration .getPackage ());
9887 break ;
9988 case FILE :
10089 String filePath = myConfiguration .getFilePath ();
@@ -111,22 +100,23 @@ private void fillCommandLineWithParameters(@NotNull GeneralCommandLine commandLi
111100 if (StringUtil .isEmpty (importPath )) {
112101 throw new ExecutionException ("Cannot find import path for " + filePath );
113102 }
114-
115- commandLine . addParameter (importPath );
103+
104+ executor . addParameters (importPath );
116105 Collection <String > testNames = ContainerUtil .newLinkedHashSet ();
117106 for (GoFunctionDeclaration function : ((GoFile )file ).getFunctions ()) {
118107 ContainerUtil .addIfNotNull (testNames , GoTestFinder .getTestFunctionName (function ));
119108 }
120- addFilterParameter (commandLine , "^" + StringUtil .join (testNames , "|" ) + "$" );
109+ addFilterParameter (executor , "^" + StringUtil .join (testNames , "|" ) + "$" );
121110 break ;
122111 }
123112 String pattern = myConfiguration .getPattern ();
124- addFilterParameter (commandLine , pattern );
113+ addFilterParameter (executor , pattern );
114+ return executor ;
125115 }
126116
127- private static void addFilterParameter (@ NotNull GeneralCommandLine commandLine , String pattern ) {
117+ private static void addFilterParameter (@ NotNull GoExecutor executor , String pattern ) {
128118 if (StringUtil .isNotEmpty (pattern )) {
129- commandLine .addParameters ("-run" , pattern );
119+ executor .addParameters ("-run" , pattern );
130120 }
131121 }
132122}
0 commit comments