Re: [IronPython] InvalidProgramException exception with NUnit

2008-10-01 Thread Curt Hagenlocher
On Tue, Sep 30, 2008 at 7:19 AM, Fernando Correia
[EMAIL PROTECTED] wrote:

 The sample test I provided runs without problem when it is executed
 directly by NUnit, but fails if NUnit is being called by some other
 layer, like the TestDriven.NET plugin for Visual Studio or the NCover
 code coverage tool.

I don't have either of these tools.  Do you know of a freely-available
substitute that could work instead?

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] InvalidProgramException exception with NUnit

2008-10-01 Thread Fernando Correia
2008/10/1 Curt Hagenlocher [EMAIL PROTECTED]:
 I don't have either of these tools.  Do you know of a freely-available
 substitute that could work instead?

Curt, no, but both TestDriven.NET and NCover have editions that can be
freely downloaded.

NCover has a 30-day trial version as well as free-to-use discontinued
versions: http://www.ncover.com/download/discontinued

TestDriven.NET also can be freely downloaded for trial and for
open-source development: http://www.testdriven.net/download.aspx

I realize that this issue won't affect too many people (not everyone
uses NDepend and NUnit, after all).

But if you plan to look into this problem I think I can provide you
with a test scenario in the form of a batch file that executes
NDepend, that executes NUnit, that executes a test fixture that uses
IronPython...
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] InvalidProgramException exception with NUnit

2008-09-30 Thread Fernando Correia
2008/9/29 Curt Hagenlocher [EMAIL PROTECTED]:
 Does it work correctly under NUnit if you disable shadow copying?

The sample test I provided runs without problem when it is executed
directly by NUnit, but fails if NUnit is being called by some other
layer, like the TestDriven.NET plugin for Visual Studio or the NCover
code coverage tool.

This behavior happens in both my desktop and in our build server, and
both within Visual Studio and in our command-line based build.

The use of the /noshadow parameter did not affect the results.

This behavior is probably linked to some difference in process or
AppDomain when NUnit is executed within another tool. I wouldn't be
able to tell what is the difference, though.

It only affects testing of IronPython code, and only when the import
command is used in the script.

The exception is raised at line 276 of CallSite.cs:

result = caller(ruleTarget, site, args);

In the stack trace it appears as (line breaks added):

Microsoft.Scripting.Core.dll!Microsoft.Scripting.Actions.CallSite
Microsoft.FuncMicrosoft.Scripting.Actions.CallSite,Microsoft.Scripting.Runtime.CodeContext,
object,string,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,
IronPython.Runtime.PythonTuple,object.UpdateAndExecute(object[] args
= {object[6]}) Line 276 C#

caller is:

-   caller  {Method = {System.Object
Call6[CodeContext,Object,String,IAttributesCollection,IAttributesCollection,PythonTuple,Object](Microsoft.Func`8[Microsoft.Scripting.Actions.CallSite,Microsoft.Scripting.Runtime.CodeContext,
System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,
IronPython.Runtime.PythonTuple,System.Object],
Microsoft.Scripting.Actions.CallSite,
System.Object[])}}  
Microsoft.Scripting.Actions.MatchCallerTargetMicrosoft.FuncMicrosoft.Scripting.Actions.CallSite,
Microsoft.Scripting.Runtime.CodeContext,object,string,Microsoft.Scripting.IAttributesCollection,
Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,object

And the Call6 function is:

/// Matchcaller - arity 6
internal static object Call6T0, T1, T2, T3, T4, T5,
TRet(FuncCallSite, T0, T1, T2, T3, T4, T5, TRet target, CallSite
site, object[] args) {
return (object)target(site, (T0)args[0], (T1)args[1],
(T2)args[2], (T3)args[3], (T4)args[4], (T5)args[5]);
}

But a breakpoint set at Call6 never is reached while debugging this issue.
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] InvalidProgramException exception with NUnit

2008-09-29 Thread Fernando Correia
Dino, thanks for your support.

The modified code still aborts under NUnit, so it is not related to
the configuration. The program runs correctly outside NUnit, but
raises an InvalidProgramException when executed as a unit test.

I had a similar problem with a previous version of IronPython that
disappeared in another release. Granted that NUnit must be doing
something to the execution context, but it would really be a shame if
code that uses IronPython could not be tested under NUnit.

Please notice that until Beta 4 this kind of test was working. The
exception started with Beta 5.

Regards.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting;
using IronPython.Hosting;
using NUnit.Framework;

namespace HelloDLRWorld
{
[TestFixture]
public class DlrTest2
{
public static void Main(string[] args)
{
var test = new DlrTest2();
test.ImportTest();
}

[Test]
public void ImportTest()
{
ScriptRuntime runtime = Python.CreateRuntime();
runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly);
runtime.LoadAssembly(typeof(System.Double).Assembly);
ScriptEngine pyEng = runtime.GetEngine(IronPython);
ScriptSource source = pyEng.CreateScriptSourceFromString(@
import System.Diagnostics
output='hello world from DLR/IronPython!'
System.Diagnostics.Debug.WriteLine(output)
, SourceCodeKind.Statements);
ScriptScope scope = pyEng.CreateScope();
source.Execute(scope);
object outputMsg = scope.GetVariable(output);
Console.WriteLine(outputMsg.ToString());
}
}
}
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] InvalidProgramException exception with NUnit

2008-09-29 Thread Curt Hagenlocher
Does it work correctly under NUnit if you disable shadow copying?

On Mon, Sep 29, 2008 at 10:41 AM, Fernando Correia 
[EMAIL PROTECTED] wrote:

 Dino, thanks for your support.

 The modified code still aborts under NUnit, so it is not related to
 the configuration. The program runs correctly outside NUnit, but
 raises an InvalidProgramException when executed as a unit test.

 I had a similar problem with a previous version of IronPython that
 disappeared in another release. Granted that NUnit must be doing
 something to the execution context, but it would really be a shame if
 code that uses IronPython could not be tested under NUnit.

 Please notice that until Beta 4 this kind of test was working. The
 exception started with Beta 5.

 Regards.

 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Text;
 using Microsoft.Scripting.Hosting;
 using Microsoft.Scripting;
 using IronPython.Hosting;
 using NUnit.Framework;

 namespace HelloDLRWorld
 {
[TestFixture]
public class DlrTest2
{
public static void Main(string[] args)
{
var test = new DlrTest2();
test.ImportTest();
}

[Test]
public void ImportTest()
{
ScriptRuntime runtime = Python.CreateRuntime();
runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly);
runtime.LoadAssembly(typeof(System.Double).Assembly);
ScriptEngine pyEng = runtime.GetEngine(IronPython);
ScriptSource source = pyEng.CreateScriptSourceFromString(@
 import System.Diagnostics
 output='hello world from DLR/IronPython!'
 System.Diagnostics.Debug.WriteLine(output)
 , SourceCodeKind.Statements);
ScriptScope scope = pyEng.CreateScope();
source.Execute(scope);
object outputMsg = scope.GetVariable(output);
Console.WriteLine(outputMsg.ToString());
}
}
 }
 ___
 Users mailing list
 Users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com