Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Src/IronPythonTest/Cases/CaseExecuter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ private int GetScopeTest(TestInfo testcase) {
}

private int GetResult(TestInfo testcase, ScriptEngine engine, ScriptSource source, string testPath, string workingDir) {
int res = 0;
var path = Environment.GetEnvironmentVariable("IRONPYTHONPATH");
if (string.IsNullOrEmpty(path)) {
Environment.SetEnvironmentVariable("IRONPYTHONPATH", IRONPYTHONPATH);
Expand All @@ -257,23 +256,22 @@ private int GetResult(TestInfo testcase, ScriptEngine engine, ScriptSource sourc
var scope = engine.CreateScope();
engine.GetSysModule().SetVariable("argv", List.FromArrayNoCopy(new object[] { source.Path }));
var compiledCode = source.Compile(new IronPython.Compiler.PythonCompilerOptions() { ModuleName = "__main__" });

var task = Task<int>.Run(() => {
try {
return engine.Operations.ConvertTo<int>(compiledCode.Execute(scope) ?? 0);
} catch (SystemExitException ex) {
return ex.GetExitCode(out object otherCode);
return ex.GetExitCode(out object _);
}
});

if (!task.Wait(testcase.Options.Timeout)) {
NUnit.Framework.TestContext.Error.WriteLine($"{testcase.Name} timed out after {testcase.Options.Timeout / 1000.0} seconds.");
res = -1;
return -1;
}
return task.Result;
} finally {
Environment.CurrentDirectory = cwd;
}
return res;
}
}
}