[Mono-devel-list] Detecting Mono

Charlie Poole cpoole at pooleconsulting.com
Mon Feb 16 12:52:48 EST 2004


Hi Jarek,

Elaborating on my earlier reply to Nick - Nunit itself /is/ one of those
apps that runs on multiple platforms and needs this facility. Currently,
we detect Win98 /in/ the test for AssemblyWatcher and just pass it if we
are on that platform. This seems better to me than ignoring, as yellow
is just another kind of red to me. :-)

That's where the logic comes from for simply leaving things out of the
test tree if they are for some other platform: they can never be run,
and none of the three colors really makes sense.

Now that I think of it, an ignore type check is probably at least as
common as a positive check. The syntax I was imagining was something
like:

	[Platform("net-1.0,net-1.1")]

Perhaps an alternative would be to also support

	[Platform( Exclude="mono" )]

Charlie Poole
cpoole at pooleconsulting.com



> -----Original Message-----
> From: mono-devel-list-admin at lists.ximian.com 
> [mailto:mono-devel-list-admin at lists.ximian.com] On Behalf Of 
> Jaroslaw Kowalski
> Sent: Monday, February 16, 2004 9:09 AM
> To: Nick Drochak; 'Charlie Poole'; mono-devel-list at lists.ximian.com
> Cc: ! nant
> Subject: Re: [Mono-devel-list] Detecting Mono
> 
> 
> > It'd be great if we had some attributes like "IgnoreDotNet" and
> "IgnoreMono"
> > with which we could decorate a test to avoid running tests 
> on specific 
> > CLR's.  My quick hack to the code would be to change
> > TestCaseBuilder.HasIgnoreAttribute() check for the full 
> Ignore, or see
> what
> > runtime we are on and check for the specific attributes accordingly.
> 
> How about using a textual name of the plaftorm for this 
> purpose? The naming schema could be adopted from NAnt, e.g:
> 
> net-1.0
> net-1.1
> net-1.2
> netcf-1.0
> sscli-1.0
> mono-1.0
> 
> This way we could even employ some wildcards. Like "mono-1.*" 
> to represent any mono v1.x.
> 
> Same thing should apply to OSes ("platforms" in NAnt 
> terminology). One should be able to run the test on a 
> particular OS or platform. For example if your test uses 
> filesystemwatcher it shouldn't be ran on Win95.
> 
> Some ideas below:
> 
> [Test]
> [IgnoreOnFramework("net-1.0")]
> void A()
> {
> }
> 
> [Test]
> [IgnoreOnFramework("net-1.1")] // this would not run on .NET 
> 1.1 void B() { }
> 
> [Test]
> [IgnoreOnFramework("net-1.*")]    // this would not run on ALL .NET
> platforms
> void C()
> {
> }
> 
> [Test]
> [IgnoreOnPlatform(Platform.Win32)]    // this would not run on Win32
> platforms
> void D()
> {
> }
> 
> [Test]
> [IgnoreOnPlatform(Platform.Unix)]    // this would not run on 
> Unix platforms
> void E()
> {
> }
> 
> [Test]
> [RunOnPlatform(Platform.Win32)]    // this would run only on 
> Win32 platforms
> void F()
> {
> }
> 
> [Test]
> [RunOnFramework("mono-1.*")]    // this would run only on Mono
> void G()
> {
> }
> 
> There are more (open source) tools that target multiple 
> platforms/oses. I think it would be great to have some 
> agreement on this attribute usage. For example in NAnt we're 
> discussing the possibility of implementing os-specific or 
> platform-specific tasks,types or functions in a single 
> codebase. We've tentatively decided that using such 
> attributes is a way to go.
> 
> BTW. I think that the "excluded because of the framework/os" 
> status shouldn't be the same thing as "ignored" in NUnit. 
> Tests are "ignored" because they are known to temporarily 
> fail, while RunOn... and IgnoreOn... means something different here.
> 
> Jarek
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com 
> http://lists.ximian.com/mailman/listinfo/mono-> devel-list
> 





More information about the Mono-devel-list mailing list