-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] add tests on latest haxe + hashlink
- Loading branch information
Showing
14 changed files
with
273 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ package-lock.json | |
/debugger/args.txt | ||
/debugger/debug.hl | ||
/hldebug-wrapper/build | ||
*.hl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class RunCi { | ||
static var MAX_TIME_PER_TEST : Float = 2; | ||
|
||
static function main() { | ||
var basePath = Sys.getCwd(); | ||
var debuggerHL = sys.FileSystem.absolutePath(basePath + "../debugger/debug.hl"); | ||
var errorCount = 0; | ||
|
||
var tests = sys.FileSystem.readDirectory(basePath + "unit"); | ||
for( test in tests ) { | ||
var fullPath = sys.FileSystem.absolutePath(basePath + "unit/" + test); | ||
log('[INFO] $test begin'); | ||
changeDirectory(fullPath); | ||
Sys.command("haxe", ["--main", "Test", "-hl", "test.hl"]); | ||
var process = new sys.io.Process("hl", [debuggerHL, "--input", "input.txt"]); | ||
var expectedOutput = sys.io.File.getContent(fullPath + "/output.txt"); | ||
var startingTime = haxe.Timer.stamp(); | ||
var exitCode : Null<Int> = 0; | ||
while( true ) { | ||
exitCode = process.exitCode(false); | ||
var currentTime = haxe.Timer.stamp(); | ||
if( exitCode != null || currentTime - startingTime > MAX_TIME_PER_TEST ) | ||
break; | ||
} | ||
process.kill(); | ||
var output = process.stdout.readAll().toString(); | ||
process.close(); | ||
if( exitCode == null ) { | ||
errorCount ++; | ||
log('[ERROR] $test: not terminated in $MAX_TIME_PER_TEST seconds, output:\n$output'); | ||
} else if( exitCode != 0 ) { | ||
errorCount ++; | ||
log('[ERROR] $test: exitCode:$exitCode'); | ||
} else if( output != expectedOutput ) { | ||
errorCount ++; | ||
log('[ERROR] $test: output:\n$output'); | ||
} else { | ||
log('[SUCCESS] $test'); | ||
} | ||
} | ||
|
||
changeDirectory(basePath); | ||
log('[INFO] all tests end, error count: $errorCount'); | ||
if( errorCount > 0 ) { | ||
Sys.exit(1); | ||
} | ||
} | ||
|
||
static public function changeDirectory(path : String) { | ||
log('[CWD] Changing directory to $path'); | ||
Sys.setCwd(path); | ||
} | ||
|
||
static public inline function log(msg : String) { | ||
Sys.println(msg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--main RunCi | ||
-hl RunCi.hl | ||
|
||
--cmd hl RunCi.hl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class Test { | ||
public function new() { | ||
foo(10, 11); | ||
var functionvar = 15; | ||
function bar(x, y) { | ||
var pt = new Point(x, y); | ||
trace(functionvar, pt.x, pt.y); // nargs=3, captured functionvar at r0, x=pt.x=r1, y=pt.y=r2 | ||
} | ||
bar(12, 13); | ||
function bar2(x, y) { | ||
var pt = new Point(x, y); | ||
trace(pt.x, pt.y); // nargs=2, x=pt.x=r0, y=pt.y=r1 | ||
} | ||
bar2(14, 15); | ||
} | ||
function foo(x : Int, y : Int) { | ||
var pt = new Point(x, y); | ||
trace(pt.x, pt.y); // nargs=3, this at r0, x=pt.x=r1, y=pt.y=r2 | ||
} | ||
|
||
static function main() { | ||
new Test(); | ||
} | ||
} | ||
|
||
class Point { | ||
public var x : Int; | ||
public var y : Int; | ||
public inline function new(x = 0, y = 0) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--ci | ||
test.hl | ||
"b Test.hx:18" | ||
"b Test.hx:12" | ||
"b Test.hx:7" | ||
r | ||
"p this" | ||
"p pt" | ||
r | ||
"p functionvar" | ||
"p pt" | ||
r | ||
"p pt" | ||
q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
> b Test.hx:18 | ||
Breakpoint set line 18 | ||
> b Test.hx:12 | ||
Breakpoint set line 12 | ||
> b Test.hx:7 | ||
Breakpoint set line 7 | ||
> r | ||
Thread paused Test.hx:18 (Test::foo) | ||
> p this | ||
Test : Test | ||
> p pt | ||
inlined : Dynamic | ||
x = 10 : Int | ||
y = 11 : Int | ||
> r | ||
Thread paused Test.hx:7 | ||
> p functionvar | ||
15 : Int | ||
> p pt | ||
inlined : Dynamic | ||
x = 12 : Int | ||
y = 13 : Int | ||
> r | ||
Thread paused Test.hx:12 | ||
> p pt | ||
inlined : Dynamic | ||
x = 14 : Int | ||
y = 15 : Int | ||
> q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Test { | ||
static function doThrow() { | ||
throw "from doThrow"; | ||
} | ||
static function main() { | ||
try { | ||
doThrow(); | ||
} catch(e:String) { | ||
trace(e); // break here should diaplay e | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--ci | ||
test.hl | ||
"b Test.hx:9" | ||
r | ||
"p e" | ||
q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
> b Test.hx:9 | ||
Breakpoint set line 9 | ||
> r | ||
Thread paused Test.hx:9 ($Test::main) | ||
> p e | ||
"from doThrow" : String | ||
> q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Test { | ||
static function main() { | ||
var iig = new InventoryItemGroup(); | ||
var it = new Item(); | ||
var data = {count : 1, k : it}; | ||
var icon = iig.makeIcon(data); | ||
trace(icon); | ||
} | ||
} | ||
class SlotGroup<T> { | ||
public function new() {} | ||
public function makeIcon( item : SlotItem<T> ) : String { | ||
return "" + item; | ||
} | ||
} | ||
class InventoryItemGroup extends SlotGroup<Item> { | ||
override function makeIcon(item : SlotItem<Item>) { | ||
trace(item); // break here should diaplay _tmp_item | ||
return super.makeIcon(item); // break here should display item | ||
} | ||
} | ||
class Item { | ||
public function new() {} | ||
} | ||
abstract SlotItem<T>({ count : Int, k : T }) { | ||
@:from public inline static function from<T>( data : { count : Int, k : T } ) : SlotItem<T> { | ||
return cast data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--ci | ||
test.hl | ||
"b Test.hx:18" | ||
"b Test.hx:19" | ||
r | ||
"p _tmp_item" | ||
r | ||
"p item" | ||
q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
> b Test.hx:18 | ||
Breakpoint set line 18 | ||
> b Test.hx:19 | ||
Breakpoint set line 19 | ||
> r | ||
Thread paused Test.hx:18 (InventoryItemGroup::makeIcon) | ||
> p _tmp_item | ||
{...} : hl.DynObj | ||
k = Item : Item | ||
count = 1 : Int | ||
> r | ||
Thread paused Test.hx:19 (InventoryItemGroup::makeIcon) | ||
> p item | ||
{...} : hl.DynObj | ||
k = Item : Item | ||
count = 1 : Int | ||
> q |