Skip to content

Commit a30103a

Browse files
committed
Update ExecCMD
1 parent 450c195 commit a30103a

File tree

2 files changed

+43
-34
lines changed

2 files changed

+43
-34
lines changed

autoload/javaunit.vim

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ function javaunit#TestMethod(args,...)
6262
\.' '
6363
\.cwords
6464
endif
65-
let cmd = javaunit#util#EscapeCMD(cmd)
66-
call unite#start([['output/shellcmd', cmd]], {'log': 1, 'wrap': 1})
65+
call javaunit#util#ExecCMD(cmd)
6766
else
6867
if filereadable('pom.xml')
6968
let cmd='java -cp "'
@@ -87,15 +86,15 @@ function javaunit#TestMethod(args,...)
8786
\.' '
8887
\.a:args
8988
endif
90-
call unite#start([['output/shellcmd', cmd]], {'log': 1, 'wrap': 1})
89+
call javaunit#util#ExecCMD(cmd)
9190
endif
9291
endfunction
9392

9493
function javaunit#TestAllMethods()
9594
let line = getline(search("package","nb",getline("0$")))
9695
let currentClassName = split(split(line," ")[1],";")[0].".".expand("%:t:r")
9796
let cmd='java -cp "'.s:JavaUnit_tempdir.s:Psep.g:JavaComplete_LibsPath.'" com.wsdjeg.util.TestMethod '.currentClassName
98-
call unite#start([['output/shellcmd', cmd]], {'log': 1, 'wrap': 1})
97+
call javaunit#util#ExecCMD(cmd)
9998
endfunction
10099

101100

@@ -108,7 +107,7 @@ endfunction
108107

109108
function javaunit#MavenTestAll()
110109
let cmd = 'mvn test|ag --nocolor "^[^[]"'
111-
call unite#start([['output/shellcmd', cmd]], {'log': 1, 'wrap': 1})
110+
call javaunit#util#ExecCMD(cmd)
112111
endfunction
113112

114113
function javaunit#NewTestClass(classNAME)
@@ -153,29 +152,29 @@ function! javaunit#TestMain(...) abort
153152
else
154153
let currentClassName = expand("%:t:r")
155154
endif
156-
if filereadable('pom.xml')
157-
let cmd='java -cp "'
158-
\.s:JavaUnit_tempdir
159-
\.s:Psep
160-
\.getcwd()
161-
\.join(['','target','test-classes'],s:Fsep)
162-
\.s:Psep
163-
\.get(g:,'JavaComplete_LibsPath','.')
164-
\.'" '
165-
\.currentClassName
166-
\.' '
167-
\.(len(a:000) > 0 ? join(a:000,' ') : '')
168-
else
169-
let cmd='java -cp "'
170-
\.s:JavaUnit_tempdir
171-
\.s:Psep
172-
\.get(g:,'JavaComplete_LibsPath','.')
173-
\.'" '
174-
\.currentClassName
175-
\.' '
176-
\.(len(a:000) > 0 ? join(a:000,' ') : '')
177-
endif
178-
call unite#start([['output/shellcmd', cmd]], {'log': 1, 'wrap': 1})
155+
if filereadable('pom.xml')
156+
let cmd='java -cp "'
157+
\.s:JavaUnit_tempdir
158+
\.s:Psep
159+
\.getcwd()
160+
\.join(['','target','test-classes'],s:Fsep)
161+
\.s:Psep
162+
\.get(g:,'JavaComplete_LibsPath','.')
163+
\.'" '
164+
\.currentClassName
165+
\.' '
166+
\.(len(a:000) > 0 ? join(a:000,' ') : '')
167+
else
168+
let cmd='java -cp "'
169+
\.s:JavaUnit_tempdir
170+
\.s:Psep
171+
\.get(g:,'JavaComplete_LibsPath','.')
172+
\.'" '
173+
\.currentClassName
174+
\.' '
175+
\.(len(a:000) > 0 ? join(a:000,' ') : '')
176+
endif
177+
call javaunit#util#ExecCMD(cmd)
179178
endfunction
180179
let &cpo = s:save_cpo
181180
unlet s:save_cpo

autoload/javaunit/util.vim

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,25 @@ function! javaunit#util#Psep() abort
3232
endif
3333
endfunction
3434

35+
function! javaunit#util#ExecCMD(cmd)
36+
call unite#start([['output/shellcmd', s:EscapeCMD(a:cmd)]], {'log': 1, 'wrap': 1})
37+
endfunction
3538

36-
function! javaunit#util#EscapeCMD(cmd)
37-
let s:cmd = substitute(a:cmd,' ',':','g')
39+
function! s:EscapeCMD(cmd)
3840
if s:WINDOWS()
39-
let s:cmd = substitute(s:cmd,';','\\;','g')
41+
let cmd = substitute(a:cmd,' ','\\ ','g')
42+
let cmd = substitute(cmd,'\','\\\','g')
43+
let cmd = substitute(cmd,';','\\;','g')
44+
let cmd = substitute(cmd, '\t', '\\t', 'g')
45+
let cmd = substitute(cmd,':','\\:','g')
46+
else
47+
let cmd = substitute(a:cmd,' ','\\ ','g')
48+
let cmd = substitute(cmd,'\','\\\','g')
49+
let cmd = substitute(cmd,';','\\;','g')
50+
let cmd = substitute(cmd, '\t', '\\t', 'g')
51+
let cmd = substitute(cmd,':','\\:','g')
4052
endif
41-
let s:cmd = substitute(s:cmd,'\','\\\','g')
42-
let s:cmd = substitute(s:cmd, '\t', '\\t', 'g')
43-
return substitute(s:cmd,':','\\:','g')
53+
return cmd
4454
endfunction
4555

4656
let &cpo = s:save_cpo

0 commit comments

Comments
 (0)