Repository navigation
Expand file tree
/
Copy pathCPythonCases.cs
More file actions
85 lines (76 loc) · 2.93 KB
/
Copy pathCPythonCases.cs
File metadata and controls
85 lines (76 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using IronPython.Hosting;
using IronPythonTest.Util;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using NUnit.Framework;
using NUnit.Framework.Api;
namespace IronPythonTest.Cases {
[TestFixture(Category = "StandardCPython")]
class StandardCPythonCases {
private CaseExecuter executor;
[OneTimeSetUp]
public void FixtureSetUp() {
this.executor = new CaseExecuter();
}
[Test, TestCaseSource(typeof(StandardCPythonCaseGenerator))]
public int StandardCPythonTests(TestInfo testcase) {
try {
return this.executor.RunTest(testcase);
} catch (Exception e) {
Assert.Fail(this.executor.FormatException(e));
return -1;
}
}
}
[TestFixture(Category = "AllCPython")]
class AllCPythonCases {
private CaseExecuter executor;
[OneTimeSetUp]
public void FixtureSetUp() {
this.executor = new CaseExecuter();
}
[Test, TestCaseSource(typeof(AllCPythonCaseGenerator))]
public int AllCPythonTests(TestInfo testcase) {
try {
Console.Error.WriteLine(testcase.Name); // write to the error stream so it appears before the test is run
return this.executor.RunTest(testcase);
} catch (Exception e) {
Assert.Fail(this.executor.FormatException(e));
return -1;
}
}
}
class StandardCPythonCaseGenerator : CommonCaseGenerator<StandardCPythonCases> {
internal static readonly HashSet<string> STDTESTS = new HashSet<String> {
"test_grammar",
"test_opcodes",
"test_dict",
"test_builtin",
"test_exceptions",
"test_types",
"test_unittest",
"test_doctest",
"test_doctest2",
"test_support"
};
protected override IEnumerable<TestInfo> GetTests() {
string stdlib = Path.Combine(CaseExecuter.FindRoot(), "Src", "StdLib", "Lib", "test");
return STDTESTS.Select(test => new TestInfo(Path.GetFullPath(Path.Combine(stdlib, test) + ".py"), this.manifest));
}
}
class AllCPythonCaseGenerator : CommonCaseGenerator<AllCPythonCases> {
protected override IEnumerable<TestInfo> GetTests() {
string stdlib = Path.Combine(CaseExecuter.FindRoot(), "Src", "StdLib", "Lib", "test");
return Directory.GetFiles(stdlib, "test_*.py", SearchOption.AllDirectories)
.Where(file => !StandardCPythonCaseGenerator.STDTESTS.Contains(Path.GetFileNameWithoutExtension(file)))
.Select(file => new TestInfo(Path.GetFullPath(file), this.manifest))
.OrderBy(testcase => testcase.Name);
}
}
}