forked from IronLanguages/ironpython3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPythonCases.cs
More file actions
84 lines (75 loc) · 2.84 KB
/
CPythonCases.cs
File metadata and controls
84 lines (75 loc) · 2.84 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
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;
[TestFixtureSetUp]
public void FixtureSetUp() {
this.executor = new CaseExecuter();
}
[Test, TestCaseSource(typeof(StandardCPythonCaseGenerator))]
public int StandardCPythonTests(TestInfo testcase) {
try {
return this.executor.RunTest(testcase);
} catch (SyntaxErrorException e) {
Assert.Fail("SyntaxError: {3}({0}, {1}): {2}", e.Line, e.Column, e.Message, e.SourcePath);
return -1;
}
}
}
[TestFixture(Category = "AllCPython")]
class AllCPythonCases {
private CaseExecuter executor;
[TestFixtureSetUp]
public void FixtureSetUp() {
this.executor = new CaseExecuter();
}
[Test, TestCaseSource(typeof(AllCPythonCaseGenerator))]
public int AllCPythonTests(TestInfo testcase) {
try {
return this.executor.RunTest(testcase);
} catch (SyntaxErrorException e) {
Assert.Fail("SyntaxError: {3}({0}, {1}): {2}", e.Line, e.Column, e.Message, e.SourcePath);
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() {
var stdlib = @"..\..\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() {
var stdlib = @"..\..\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);
}
}
}