views:

39

answers:

1

I am trying to call MSTest.exe from a simple console app that is executed from inside an SVN pre-commit hook.

If I use TortoiseSVN to Commit, it auto-runs the console app code below.

(skip after the code to see what happens...)

// CODE

static void Main(string[] args)
{
    string testPath = @"C:\Users\myname\Documents\SVN\Test\bin\Debug\TestProject1.dll";

    string mstest = GetMSTestOutput(testPath);

    if (mstest != null)
    {
        Console.Error.WriteLine(mstest);
        Environment.Exit(1);  // I WANT it to stop here, so I can see output while testing
    }
}

private static string GetMSTestOutput(string testPath)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
    FileName = @"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe",
    UseShellExecute = false,
    CreateNoWindow = true,
    RedirectStandardOutput = true,
    RedirectStandardError = true,
    Arguments = String.Format("/testcontainer:{0}", testPath)
};

Process process = Process.Start(processStartInfo);
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
 return output;
}

// OUTPUT

This is what I see in the TortoiseSVN window:

Error: Commit failed (details follow):
Error: Commit blocked by pre-commit hook (exit code 1) with output:
Error: Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Error: Copyright (c) Microsoft Corporation. All rights reserved.
Error:
Error: File
Error: "C:\Users\myname\Documents\SVN\Test\bin\Debug\TestProject1.dll"
Error: not found .

So you can see I am calling MSTest correctly, but it's claiming the path is wrong.

BUT, if I open a VS Command Prompt manually and type the EXACT same path, the code runs without error.

What am I doing wrong?

A: 

It's possible, this may actually be a permissions issue, not a FnF issue.

Run filemon while you are executing the code, and see what is actually being requested at the OS level.

dave wanta
I ran ProcessMonitor (filemon is not available anymore), limited it to file system activity, and filtered to the process name "ControllerConsole.exe" (the name of my console app that is trying to call mstest) and I still got 786 rows and have no idea what I'm looking for.
Blackcoil
Turned out to be a permissions issue. Fixed it, and now onto another permissions issue. *groan*
Blackcoil