[Mono-devel-list] Detecting Mono

Jaroslaw Kowalski jaak at zd.com.pl
Mon Feb 16 12:08:42 EST 2004


> 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




More information about the Mono-devel-list mailing list