> >Ideally I want an application that is guaranteed to be 
> available that 
> >has stable output, so a stable test could be added to the 
> ExecTaskTest 
> >fixture.  I guess the most robust/generic way to do this would be to 
> >use a small purpose-build C# application as you suggest, but 
> is there a 
> >way to ensure this application would be generated prior to running 
> >these tests, and cleaned up afterwards?
> >  
> >
> either;
> - build it during the regular nant build process and just 
> call it form the test or
> - build it during the 'setup' phase of the test and delete it 
> during 'teardown'
> 
> 
> Ian

Okay, I've come up against an error actually implementing this...
I've added the following fixture setup to the appropriate test fixture
(NAnt.Core/Tasks/ExecTaskTest.cs):

<code>
private const string TEST_EXE_FILENAME = "ExecTestEmit.exe";
private const string EMIT_MESSAGE_FORMAT = "{0} {1}";
private const string EMIT_MESSAGE_COMMON = "Printing to";
private const string EMIT_MESSAGE_STDOUT = "Standard Output";
private const string EMIT_MESSAGE_STDERR = "Standard Error";

private static FileInfo _testExe = new
FileInfo(Path.Combine(Path.GetTempPath(),
    TEST_EXE_FILENAME));
public static FileInfo TestExecutable
{
    get { return _testExe; }
}

[TestFixtureSetUp]
public void Init() {
    string[] sourceTexts = new string[1];
    string[] sourceNames = new string[1];
    string[] imports = new string[0];
    System.Collections.IDictionary options = new
System.Collections.Hashtable();

    string outMessage = string.Format(EMIT_MESSAGE_FORMAT,
EMIT_MESSAGE_COMMON,
        EMIT_MESSAGE_STDOUT);
    string errMessage = string.Format(EMIT_MESSAGE_FORMAT,
EMIT_MESSAGE_COMMON,
        EMIT_MESSAGE_STDERR);
    sourceTexts[0] = 
        "public class ExecTestEmit {" + Environment.NewLine + 
        "    public static int Main(string[] args) {" +
Environment.NewLine + 
        "        System.Console.Out.WriteLine(\"" + outMessage + "\");"
+
            Environment.NewLine + 
        "        System.Console.Error.WriteLine(\"" + errMessage +
"\");" +
            Environment.NewLine + 
        "        return 0;" + Environment.NewLine + 
        "    }" + Environment.NewLine + 
        "}";
    sourceNames[0] = "ExecTestEmit.cs";
    options["target"] = "exe";
    try {
        Microsoft.CSharp.CompilerError[] errors =
            Microsoft.CSharp.Compiler.Compile(sourceTexts, sourceNames,
            TestExecutable.FullName, imports, options);
    } catch (Exception e) {
        System.Console.Error.WriteLine("{0}{2}{1}", e.Message,
e.StackTrace,
            Environment.NewLine);
    }
}
</code>

If this code is run standalone, it works correctly: an executable is
produced in the expected location, which runs with the expected output.

If run as part of the NAnt suite of tests, the following exception is
raised:
[nunit2] Cannot change thread mode after it is set.
[nunit2]    at Microsoft.CSharp.Compiler.CallFunctionShim(String
dllname, String apiname, String[] texts, COMPILEPARAMS& p, String ver,
Void* reserved)
[nunit2]    at Microsoft.CSharp.Compiler.Compile(String[] sourceTexts,
String[] sourceTextNames, String target, String[] imports, IDictionary
options)
[nunit2]    at Tests.NAnt.Core.Tasks.ExecTaskTest.Init() in
c:\app\NAnt\tests\NAnt.Core\Tasks\ExecTaskTest.cs:line 120


Does anyone have any suggestions on what is causing this error, or what
can be done to work around it?

-- Troy

Disclaimer Message:

This message contains confidential information and is intended only for the 
individual(s) named.  If you are not the named addressee you should not disseminate, 
distribute or copy this e-mail. Please immediately delete it and all copies of it from 
your system, destroy any hard copies of it, and notify the sender. E-mail transmission 
cannot be guaranteed to be secure or error-free as information could be intercepted, 
corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. To the 
maximum extent permitted by law, Immersive Technologies Pty. Ltd. does not accept 
liability for any errors or omissions in the contents of this message which arise as a 
result of e-mail transmission.


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to