wsdjeg/JavaUnit.vim

Wrong path for the bin folder on GVim (MS Windows)

adelarsq opened this issue · 44 comments

There is no file separator on the path used:

a

ok i will fix it,by the way ,i think MS is not a good os for dev,you can use Linux or mac

I agree with you. Unfortunately I have to use 😢

@adelarsq
can you try with the latest version

The bin folder path is wrong (without file separators):

a

Says that wasn't possible to load the com.wsdjeg.util.TestMethod class on the C:/Users/SOFT1182/vim/plugged/JavaUnit.vim/bin folder.

ok it is my fault,will fix it tonight

👍

@adelarsq which command do you use?
can you show me the reproduce step?

and what is your out put of
echo g:JavaUnit_tempdir in vim

The command JavaUnitTest on the JUnit test file.
I just notice that the default classpath for Java is not being taken correctly now. I will try to figure out what is wrong before send a reply. On Monday if not tomorrow I will try. It's from my work machine.

if you want use JavaUnitTest,you shoud keep your cursor on the methed name.

@adelarsq
can you try with the latest version

Didn't work.

The compiled Test classes are not being found. JavaUnitTest shows:

[output/shellcmd] command: java -cp "C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin;C:...asses;C:\workspace\java\JavaUnitTest\target\test-classes" com.wsdjeg.util.TestMethod ATest 

and:

Error: It could not find or load the main class arget

Global variables:

echo g:JavaUnit_Home
C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim

echo g:JavaUnit_tempdir
C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin

echo g:JavaComplete_LibsPath
C:\Users\SOFT1182\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\SOFT1182\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\workspace\java\JavaUnitTest\target\classes;C:\workspace\java\JavaUnitTest\target\test-classes

There are only 2 files on the project:

  • C:\workspace\java\JavaUnitTest\src\test\java\ATest.java
import org.junit.*;
public class ATest {
    @Test
    public void test1(){ System.out.println("test"); }
}
  • C:\workspace\java\JavaUnitTest\pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.test</groupId>
    <artifactId>javaunittest</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>javaunittest</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

is the bin dir empty,
C:\Users\SOFT1182.vim\plugged\JavaUnit.vim\bin
i mean does the TestMethod.java be compiled?

Isn't empty. The TestMethod is there:

C:\Users\MyUser\.vim\plugged\JavaUnit.vim\bin (master)
λ ls -Rl
.:
total 0
drwxr-xr-x    3 MyUser Administ        0 Dec 26 15:09 com/
-rw-r--r--    1 MyUser Administ        0 Dec 18 13:46 test.txt

./com:
total 0
drwxr-xr-x    3 MyUser Administ        0 Dec 26 15:09 wsdjeg/

./com/wsdjeg:
total 0
drwxr-xr-x    3 MyUser Administ        0 Dec 26 15:09 util/

./com/wsdjeg/util:
total 1
-rw-r--r--    1 MyUser Administ     1909 Dec 26 15:09 TestMethod.class

Where should be the *.class file for the compiled test (ATest)?

it should be in target/test-classes
before use this plugin ,you should install scrooloose/syntastic,also make sure target/classes and target/test-classes these two dir exists.

Syntastic is working, but this two directories are empty. Maybe the class path for syntastic then. I will see tomorrow. I will sleep a little 😴

sorry ,I did not realize we are not in same time zone

if you want syntastic compile the java file into target/classes ,you need to add this to your vimrc

let g:syntastic_java_javac_delete_output = 0

No problem.
Nice, I will try.

Did work. The *.class is there now:

λ ls C:\workspace\java\JavaUnitTest\target\test-classes
ATest.class

But after run :JavaUnitTest on the class shows this message:

 Error: It could not find or load the main class arget\classes;C:\workspace\java\JavaUnitTest

Apparently the path for the test-classes folder is being taken wrong.

can you show me the pic ,i want to see what the cmd is.
just like the pic you show above

I translated the portuguese message before send to you, but is the same.
a

On the terminal the same command works:

λ java -cp "C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin;C:...;C:\workspace\java\JavaUnitTest\target\test-classes" com.wsdjeg.util.TestMethod ATest
Picked up _JAVA_OPTIONS: "-Djava.net.preferIPv4Stack=true"
startting : className:ATest methodName :test1()
result:
test
success!

you need to put you cursor on the methodname test1(),then you can use JavaUnitTest without args,
or you can use JavaUnitTest test1 or JavaUnitTestAll

I didn't notice, sorry. This is the print:
a

But on the terminal works fine:

λ java -cp "C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin;C:...;C:\workspace\java\JavaUnitTest\target\test-classes" com.wsdjeg.util.TestMethod ATest test1 
Picked up _JAVA_OPTIONS: "-Djava.net.preferIPv4Stack=true"                                                                                                   
startting : className:ATest methodName :test1()                                                                                                              
result:                                                                                                                                                      
test                                                                                                                                                         
success!                                                                                                                                               

can you try with the latest version

Didn't work. Using the generated command alone gives the same error.

Unite -log -wrap output/shellcmd:java\ -cp\ \"C\:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin\;C\:\workspace\java\JavaUnitTest\target\test-classes\;C\:\Users\SOFT1182\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar\;C\:\Users\SOFT1182\.m2\repository\junit\junit\4.12\junit-4.12.jar\;C\:\workspace\java\JavaUnitTest\target\classes\;C\:\workspace\java\JavaUnitTest\target\test-classes\"\ com.wsdjeg.util.TestMethod\ ATest\ test1

So the problem is with the Unite call.

@adelarsq ok I got it ,because the unite change escape \t
the command contains \targer

Sorry for the delay. I did take a break. It has the same error (test class not found).
The Unite call:

Unite -log -wrap output/shellcmd:java\\ -cp\\ \\"C\:\\Users\\SOFT1182\\.vim\\plugged\\JavaUnit.vim\\bin\;C\:\\workspace\\java\\JavaUnitTest\\target\\test-classes\;C\:\\Users\\SOFT1182\\.m2\\repository\\org\\hamcrest\\hamcrest-core\\1.3\\hamcrest-core-1.3.jar\;C\:\\Users\\SOFT1182\\.m2\\repository\\junit\\junit\\4.12\\junit-4.12.jar\;C\:\\workspace\\java\\JavaUnitTest\\target\\classes\;C\:\\workspace\\java\\JavaUnitTest\\target\\test-classes\\"\\ com.wsdjeg.util.TestMethod\\ ATest\\ test1

The java call:

[output/shellcmd] command: java -cp "C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin;C:...;C:\workspace\java\JavaUnitTest\target\test-classes" com.wsdjeg.util.TestMethod ATest test1

which class can not be found ,can you update to the latest Version ,and test only one file ~/test/Foo.java
also you need add this to your vimrc

let g:syntastic_java_javac_delete_output = 0
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0

and show me the sreenshot

The screenshot:
a

But running the same command on the command line works:

λ java -cp "C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin;." com.wsdjeg.util.TestMethod Foo test1
Picked up _JAVA_OPTIONS: "-Djava.net.preferIPv4Stack=true"
startting : className:Foo methodName :test1()
result:
test
success!

The problem is that the class com.wsdjeg.util.TestMethod isn't found. But it is there:

λ ls -Rl C:/Users/SOFT1182/.vim/plugged/JavaUnit.vim/bin
C:/Users/SOFT1182/.vim/plugged/JavaUnit.vim/bin:
total 0
drwxr-xr-x    1 SOFT1182 Administ        0 Jan  5 13:42 com/
-rw-r--r--    1 SOFT1182 Administ        0 Dec 18 13:46 test.txt

C:/Users/SOFT1182/.vim/plugged/JavaUnit.vim/bin/com:
total 0
drwxr-xr-x    1 SOFT1182 Administ        0 Jan  5 13:42 wsdjeg/

C:/Users/SOFT1182/.vim/plugged/JavaUnit.vim/bin/com/wsdjeg:
total 0
drwxr-xr-x    1 SOFT1182 Administ        0 Jan  5 13:42 util/

C:/Users/SOFT1182/.vim/plugged/JavaUnit.vim/bin/com/wsdjeg/util:
total 1
-rw-r--r--    1 SOFT1182 Administ     1909 Jan  5 13:42 TestMethod.class

Really strange 😮

I can not fixed it ,need help

hi @mattn here is an issue with windows, I have tried with many commits,but still can not fix it, can you help me ,thanks a lot.

this plugin is for test java files,it works well in my linux os,but in windows ,has a lot of issues

I was confused by the issue above

neovim/neovim#3980 (comment)

hi @Shougo I think this feature shoud be add into Unite output:shellcmd

@wsdjeg I see the code.
You should use unite#start() instead :Unite.

call unite#start([['output/shellcmd', cmd]], {'log': 1, 'wrap': 1})

thanks for your help

@adelarsq I have make some changes,can you test the latest version?

The command on the line 38 works:

C:\
λ java -cp "C:\Users\SOFT1182\.vim\plugged\JavaUnit.vim\bin;C:\Users\SOFT1182\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\SOFT1182\.m2\repositor y\junit\junit\4.12\junit-4.12.jar;C:\workspace\java\JavaUnitTest\target\classes;C:\workspace\java\JavaUnitTest\target\test-classes" com.wsdjeg.util.TestMethod ATest test1
Picked up _JAVA_OPTIONS: "-Djava.net.preferIPv4Stack=true"
startting : className:ATest methodName :test1()
result:
test
success!

But there are something on the unite call. I don't know how this Unite call works, by may be necessary deal with chars like ", :, \ and space.
a

I have trid many times,but still can not fix it,as I am not win user,unite need escape space and :

I have no access to a win machine until next month, since I am taking a break. I will try figure out something when back.

thanks a lot

@Shougo I still can not fix this issue,I hava install unit vimproc and this plugin win Win7;
now the cmd is

java -cp "C:\User\Administator\.vim\bundle\JavaUnit.vim\bin;." com.wsdjeg.util.TestMethod Foo run

how can I use
call unite#start([['output/shellcmd', cmd]], {'log': 1, 'wrap': 1})

Fixed
qq 20160205125849
qq 20160205125732

Thanks @wsdjeg 👍

welcome