forked from HaxeFoundation/hxcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunTests.hx
More file actions
168 lines (138 loc) · 3.78 KB
/
RunTests.hx
File metadata and controls
168 lines (138 loc) · 3.78 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class RunTests
{
static var baseDir:String;
static var errors = new Array<String>();
static var cppAst:Array<String> = [];
static var sysArgs = new Array<String>();
static var binDir = "";
static var ext = "";
static var m64 = true;
static var m64Def = "HXCPP_M64";
static var windows = false;
static var sep = "/";
public static function cffi()
{
setDir("cffi/project");
command("haxelib", ["run", "hxcpp", "build.xml", "-debug", '-D$m64Def']);
setDir("cffi");
command("haxe", ["compile.hxml", "-debug"] );
command("haxe", ["compile-neko.hxml", "-debug"] );
copy('project/ndll/$binDir/prime$ext', 'bin/neko/prime.ndll');
setDir("cffi");
command("bin" + sep + "cpp" + sep + "TestMain-debug",[]);
setDir("cffi/bin/neko");
command("neko", ["TestMain.n"]);
}
public static function runHaxe()
{
setDir("haxe");
command("haxe", ["compile.hxml", "-debug", "-D", m64Def].concat(cppAst) );
command("bin" + sep + "TestMain-debug",[]);
}
public static function opMatrix()
{
setDir("opMatrix");
command("haxe", ["--run","MkOps.hx"] );
}
public static function native()
{
setDir("native");
command("haxe", ["compile.hxml"] );
command("bin" + sep + "Native",[]);
}
public static function std32()
{
setDir("std");
command("haxe", ["compile32.hxml"] );
command("cpp32"+sep+"Test",[]);
}
public static function std64()
{
setDir("std");
command("haxe", ["compile64.hxml"] );
command("cpp64"+sep+"Test",[]);
}
public static function setDir(name:String)
{
Sys.println("Enter " + baseDir + "/" + name);
Sys.setCwd(baseDir + "/" + name);
}
public static function command(prog:String, args:Array<String>)
{
Sys.println( prog + " " + args.join(" ") );
var code = Sys.command(prog,args);
if (code!=0)
throw( "failed:" + prog + " " + args.join(" ") );
}
public static function run(name:String, func:Void->Void)
{
var args = sysArgs;
if (args.length>0 && args.indexOf(name)<0)
{
Sys.println("Skip test " + name);
return;
}
try
{
func();
}
catch(e:Dynamic)
{
trace('Error running $name : $e');
errors.push('Error running $name : $e');
}
}
public static function copy(from:String, to:String)
{
if (windows)
{
from = from.split("/").join("\\");
to = to.split("/").join("\\");
}
command( windows ? "copy" : "cp", [ from, to ] );
}
public static function main()
{
var systemName = Sys.systemName().toLowerCase();
switch(systemName.substr(0,3) )
{
case "mac":
m64 = true;
binDir = "Mac64";
ext = ".dylib";
case "lin":
m64 = true;
binDir = "Linux64";
ext = ".dso";
case "win":
m64 = false;
binDir = "Windows";
ext = ".dll";
windows = true;
sep = "\\";
default:
throw 'Unknown system "$systemName"';
}
sysArgs = Sys.args();
if (sysArgs.remove("-cppast"))
cppAst = ["-D", "cppast"];
m64Def = m64 ? "HXCPP_M64" : "HXCPP_M32";
baseDir = Sys.getCwd();
run("cffi", cffi);
run("opMatrix", opMatrix);
run("haxe", runHaxe);
run("std32", std32);
run("std64", std64);
run("native", native);
Sys.println("");
if (errors.length==0)
{
Sys.println("All good!");
Sys.exit(0);
}
Sys.println("There were errors:");
for(error in errors)
Sys.println(error);
Sys.exit(-1);
}
}