mindriven / TeamCity-OpenCoverRunner

14 stars 0 forks source link

Different partitions causing problems #8

Closed aling93 closed 8 years ago

aling93 commented 8 years ago

Can you tell me how to get around this?

java.io.FileNotFoundException: Found multiple or none files(0) matching directory discovery pattern

Searched in: X:\BuildAgent\work\9385ca14d240412f

Searched for: "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
[18:48:47]
[Step 5/5] java.io.FileNotFoundException: Found multiple or none files(0) matching directory discovery pattern
Searched in: X:\BuildAgent\work\9385ca14d240412f
Searched for: "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
    at mindriven.buildServer.OpenCoverRunner.agent.Utils.OpenCoverRunnerDirectoryScanner.throwScanningResultInconclusiveException(OpenCoverRunnerDirectoryScanner.java:64)
    at mindriven.buildServer.OpenCoverRunner.agent.Utils.OpenCoverRunnerDirectoryScanner.scanForSinglePath(OpenCoverRunnerDirectoryScanner.java:33)
    at mindriven.buildServer.OpenCoverRunner.agent.OpenCover.ArgumentsProvider.getTestsRunnerPath(ArgumentsProvider.java:97)
    at mindriven.buildServer.OpenCoverRunner.agent.OpenCover.ArgumentsProvider.getArguments(ArgumentsProvider.java:48)
    at mindriven.buildServer.OpenCoverRunner.agent.OpenCoverRunnerCommandLine.constructExecutionCommand(OpenCoverRunnerCommandLine.java:69)
    at mindriven.buildServer.OpenCoverRunner.agent.OpenCoverRunnerCommandLine.fillCmdFileWithContent(OpenCoverRunnerCommandLine.java:60)
    at mindriven.buildServer.OpenCoverRunner.agent.OpenCoverRunnerCommandLine.getExecutablePath(OpenCoverRunnerCommandLine.java:49)
    at jetbrains.buildServer.agent.runner2.GenericCommandLineBuildProcess$3.getExecutablePath(GenericCommandLineBuildProcess.java:159)
    at jetbrains.buildServer.agent.runner2.GeneralCommandLineFactory.checkCommandLine(GeneralCommandLineFactory.java:88)
    at jetbrains.buildServer.agent.runner2.GeneralCommandLineFactory.<init>(GeneralCommandLineFactory.java:35)
    at jetbrains.buildServer.agent.runner2.GenericCommandLineBuildProcess.executeProcess(GenericCommandLineBuildProcess.java:72)
    at jetbrains.buildServer.agent.runner2.GenericCommandLineBuildProcess.waitFor(GenericCommandLineBuildProcess.java:257)
    at jetbrains.buildServer.agent.impl.buildStages.runnerStages.start.CallRunnerStage.doBuildStage(CallRunnerStage.java:59)
    at jetbrains.buildServer.agent.impl.buildStages.RunnerStagesExecutor$1.callStage(RunnerStagesExecutor.java:25)
    at jetbrains.buildServer.agent.impl.buildStages.RunnerStagesExecutor$1.callStage(RunnerStagesExecutor.java:18)
    at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.callRunStage(StagesExecutor.java:78)
    at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.doStages(StagesExecutor.java:37)
    at jetbrains.buildServer.agent.impl.buildStages.RunnerStagesExecutor.doStages(RunnerStagesExecutor.java:18)
    at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.RunnerContextExecutor.callRunnerStages(RunnerContextExecutor.java:43)
    at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.StepExecutor.processNextStep(StepExecutor.java:25)
    at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.executeRunnerStep(ForEachBuildRunnerStage.java:138)
    at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.runStep(ForEachBuildRunnerStage.java:123)
    at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.executeBuildRunners(ForEachBuildRunnerStage.java:83)
    at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.doBuildStage(ForEachBuildRunnerStage.java:44)
    at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:31)
    at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:24)
    at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.callRunStage(StagesExecutor.java:78)
    at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.doStages(StagesExecutor.java:37)
    at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor.doStages(BuildStagesExecutor.java:24)
    at jetbrains.buildServer.agent.impl.BuildRunActionImpl.doStages(BuildRunActionImpl.java:70)
    at jetbrains.buildServer.agent.impl.BuildRunActionImpl.runBuild(BuildRunActionImpl.java:50)
    at jetbrains.buildServer.agent.impl.BuildAgentImpl.doActualBuild(BuildAgentImpl.java:281)
    at jetbrains.buildServer.agent.impl.BuildAgentImpl.access$100(BuildAgentImpl.java:55)
    at jetbrains.buildServer.agent.impl.BuildAgentImpl$1.run(BuildAgentImpl.java:245)
    at java.lang.Thread.run(Thread.java:744)

The teamcity working directory is on X: but the visual studio test runner is on C: . Setting working directory to C: didn't help much either.

mindriven commented 8 years ago

Hi and thanks for using my plug-in. I was trying to write a test that proves issue you've reported, but I didn't get the expected result.

Exception is pretty clear, executable is not found, but what's remarkable is that in your case (absolute executable path) this search shouldn't even be run. On your system (unlike on my) following function must return false:

    private Boolean isAbsoluteFilePath(String path)
    {
        File file = new File(path);
        return file.getAbsolutePath() == path;
    }

On my machine it returns true for the values you've provided in error report. As I do not have extensive Java expertise it is hard for me to say what can cause this issue, I've read documentation (http://docs.oracle.com/javase/7/docs/api/java/io/File.html#getAbsolutePath%28%29) but I still have no idea. Do you maybe have an idea what can that be? Can you provide all your configuration values? Maybe there is something completely outside of the picture that is causing this.

aling93 commented 8 years ago

Hi, Thanks for fast response :) . I am not able to access the TeamCity server until Monday but with this chance I've freshened up my long unused Java skills and I think that the problem is right there in front of us:

return file.getAbsolutePath() == path;

You are testing for reference equality when you should test for logical equality:

return file.getAbsolutePath().Equals(path);

What do you think ?

mindriven commented 8 years ago

Hi, please try new release (https://github.com/mindriven/TeamCity-OpenCoverRunner/releases/tag/1.0.2-Beta). What I changed is the way path is determined to be absolute. It is now done as follows:

new File(pattern).isAbsolute()

Please let me know if it helps. Accoriding to this SO thread: http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java you are likely to have correctly identified the cause of error. This would also explain whay my test is passing, compiler internalized the string and logical equality could be correctly determined using == operator. Thans for pointing this out.

aling93 commented 8 years ago

I was looking at the same thread. I will try it on Monday and let you know. Thanks!

aling93 commented 8 years ago

Error is identical...

image

No luck...can you maybe add some logging or something to see what's going on? FYI, I've asked someone to upload the release 1.0.2-Beta since I don't have direct access to TC server. I assume that release contains the fix... but then why am I seeing the same thing?

aling93 commented 8 years ago

Hi,

I was able to get it working. The problem was in the way I sent the path to Runner executable (enclosed in double quotes) which apparently isn't interpreted by Java as I would have expected. If you have time for another improvement I suggest also checking if the path provided is sent using double quotes. This might be useful because on Windows there are a lot of folders with spaces in path and users might enclose it in double quotes just to make sure it's interpreted right.

Thanks for the help, anyways! I will provide more feedback once I get to play with it for a while.

mindriven commented 8 years ago

Great that you got it working. Now this makes me wonder if I should actually trim quotation marks from paths berfore using them, or should I just put remark in the documentation. Probably both would make sense. Thanks for the improvement proposal (I've made a note here https://github.com/mindriven/TeamCity-OpenCoverRunner/issues/9). I am gladly awaiting more feedback! :)