Skip to content

Commit 578972c

Browse files
authored
Skip test if exception SkipTest is raised (#1895)
* Skip test if exception `SkipTest` is raised * "Enable" a few modules that are not available on all platforms
1 parent 3a477d2 commit 578972c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

tests/IronPython.Tests/Cases/CPythonCasesManifest.ini

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,6 @@ NotParallelSafe=true # Creates/deletes a directory with static name 'xx'
472472
[CPython.test_glob]
473473
RunCondition=NOT $(IS_POSIX) # TODO: figure out
474474

475-
[CPython.test_grp]
476-
RunCondition=$(IS_POSIX)
477-
Reason=Only valid for Unix
478-
479475
[CPython.test_httplib] # IronPython.test_httplib_stdlib
480476
Ignore=true
481477
Reason=Blocking
@@ -713,7 +709,7 @@ Reason=Blocking
713709
[CPython.test_posix]
714710
RunCondition=$(IS_POSIX)
715711
Ignore=true
716-
Reason=unittest.case.SkipTest: No module named 'posix'
712+
Reason=AttributeError: module 'posix' has no attribute 'chown'
717713

718714
[CPython.test_posixpath]
719715
Ignore=true
@@ -729,10 +725,6 @@ Reason=unittest.case.SkipTest: No module named 'fcntl'
729725
[CPython.test_pulldom]
730726
Ignore=true
731727

732-
[CPython.test_pwd]
733-
RunCondition=$(IS_POSIX)
734-
Reason=Only valid for Unix
735-
736728
[CPython.test_py_compile]
737729
Ignore=true
738730
Reason=NotImplementedError: sys.implementation.cache_tag is None

tests/IronPython.Tests/Cases/CaseExecuter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using IronPython.Hosting;
1818
using IronPython.Runtime;
1919
using IronPython.Runtime.Exceptions;
20+
using IronPython.Runtime.Types;
2021

2122
using Microsoft.Scripting;
2223
using Microsoft.Scripting.Hosting;
@@ -300,6 +301,13 @@ private int GetResult(TestInfo testcase, ScriptEngine engine, ScriptSource sourc
300301
#pragma warning disable SYSLIB0006 // 'Thread.ResetAbort is not supported and throws PlatformNotSupportedException.'
301302
Thread.ResetAbort();
302303
#pragma warning restore SYSLIB0006
304+
} catch (Exception ex) when (ex.GetPythonException() is not null and var pex) {
305+
if (DynamicHelpers.GetPythonType(pex).Name == "SkipTest") {
306+
NUnit.Framework.TestContext.Progress.WriteLine($"Test {testcase.Name} skipped: {pex}");
307+
res = 0;
308+
} else {
309+
throw;
310+
}
303311
}
304312
}, maxStackSize) {
305313
IsBackground = true

0 commit comments

Comments
 (0)