[TravisCI] CI all the things!!

This commit is contained in:
Andy Li
2015-12-07 17:35:18 +08:00
parent 22fa9085cf
commit 9f1473d77d
20 changed files with 307 additions and 83 deletions
+61
View File
@@ -0,0 +1,61 @@
language: haxe
os:
- linux
- osx
haxe:
- "3.2.1"
- development
addons:
apt:
packages:
# Python
- python3
# PHP
- php5-cli
# C#
- mono-devel
- mono-mcs
# Flash
- libcurl3:i386
- libglib2.0-0:i386
- libx11-6:i386
- libxext6:i386
- libxt6:i386
- libxcursor1:i386
- libnss3:i386
- libgtk2.0-0:i386
install:
# os-specific config
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
export DISPLAY=:99.0;
export AUDIODEV=null;
elif [ "${TRAVIS_OS_NAME}" = "osx" ]; then
brew update;
brew install mono;
brew install python3;
fi
# Download and setup a standalone flash player debugger
- haxe flash/install.hxml
# Install haxelibs
- haxelib install hxcpp
- haxelib install hxjava
- haxelib install hxcs
- haxelib list
script:
- pushd script;
haxe build.hxml;
popd;
- haxe build-interp.hxml
- haxe build-neko.hxml && neko bin/Test.n
- haxe build-js.hxml && node bin/Test.js
- haxe build-java.hxml && java -jar bin/Test.jar
- haxe build-cs.hxml && mono bin/bin/Test.exe
- haxe build-cpp.hxml && ./bin/Test
- haxe build-flash.hxml -D fdb && haxe flash/run.hxml bin/Test.swf
- haxe build-php.hxml && php bin/index.php
- haxe build-python.hxml && python3 bin/Test.py
+2
View File
@@ -1,6 +1,8 @@
hscript
=======
[![TravisCI Build Status](https://travis-ci.org/HaxeFoundation/hscript.svg?branch=master)](https://travis-ci.org/HaxeFoundation/hscript)
Parse and evalutate Haxe expressions.
+92 -77
View File
@@ -1,8 +1,8 @@
import hscript.Macro;
import haxe.unit.*;
class Test {
static function test(x,v:Dynamic,?vars : Dynamic,allowTypes=false) {
class Test extends TestCase {
function assertScript(x,v:Dynamic,?vars : Dynamic,allowTypes=false) {
var p = new hscript.Parser();
p.allowTypes = allowTypes;
var program = p.parseString(x);
@@ -13,85 +13,100 @@ class Test {
for( v in Reflect.fields(vars) )
interp.variables.set(v,Reflect.field(vars,v));
var ret : Dynamic = interp.execute(program);
if( v != ret ) throw ret+" returned while "+v+" expected";
assertEquals(v, ret);
}
function test():Void {
assertScript("0",0);
assertScript("0xFF", 255);
#if !(php || python)
#if haxe3
assertScript("0xBFFFFFFF", 0xBFFFFFFF);
assertScript("0x7FFFFFFF", 0x7FFFFFFF);
#elseif !neko
assertScript("n(0xBFFFFFFF)", 0xBFFFFFFF, { n : haxe.Int32.toNativeInt });
assertScript("n(0x7FFFFFFF)", 0x7FFFFFFF, { n : haxe.Int32.toNativeInt } );
#end
#end
assertScript("-123",-123);
assertScript("- 123",-123);
assertScript("1.546",1.546);
assertScript(".545",.545);
assertScript("'bla'","bla");
assertScript("null",null);
assertScript("true",true);
assertScript("false",false);
assertScript("1 == 2",false);
assertScript("1.3 == 1.3",true);
assertScript("5 > 3",true);
assertScript("0 < 0",false);
assertScript("-1 <= -1",true);
assertScript("1 + 2",3);
assertScript("~545",-546);
assertScript("'abc' + 55","abc55");
assertScript("'abc' + 'de'","abcde");
assertScript("-1 + 2",1);
assertScript("1 / 5",0.2);
assertScript("3 * 2 + 5",11);
assertScript("3 * (2 + 5)",21);
assertScript("3 * 2 // + 5 \n + 6",12);
assertScript("3 /* 2\n */ + 5",8);
assertScript("[55,66,77][1]",66);
assertScript("var a = [55]; a[0] *= 2; a[0]",110);
assertScript("x",55,{ x : 55 });
assertScript("var y = 33; y",33);
assertScript("{ 1; 2; 3; }",3);
assertScript("{ var x = 0; } x",55,{ x : 55 });
assertScript("o.val",55,{ o : { val : 55 } });
assertScript("o.val",null,{ o : {} });
assertScript("var a = 1; a++",1);
assertScript("var a = 1; a++; a",2);
assertScript("var a = 1; ++a",2);
assertScript("var a = 1; a *= 3",3);
assertScript("a = b = 3; a + b",6);
assertScript("add(1,2)",3,{ add : function(x,y) return x + y });
assertScript("a.push(5); a.pop() + a.pop()",8,{ a : [3] });
assertScript("if( true ) 1 else 2",1);
assertScript("if( false ) 1 else 2",2);
assertScript("var t = 0; for( x in [1,2,3] ) t += x; t",6);
assertScript("var a = new Array(); for( x in 0...5 ) a[x] = x; a.join('-')","0-1-2-3-4");
assertScript("(function(a,b) return a + b)(4,5)",9);
assertScript("var y = 0; var add = function(a) y += a; add(5); add(3); y", 8);
assertScript("var a = [1,[2,[3,[4,null]]]]; var t = 0; while( a != null ) { t += a[0]; a = a[1]; }; t",10);
assertScript("var t = 0; for( x in 1...10 ) t += x; t", 45);
#if haxe3
assertScript("var t = 0; for( x in new IntIterator(1,10) ) t +=x; t", 45);
#else
assertScript("var t = 0; for( x in new IntIter(1,10) ) t +=x; t", 45);
#end
assertScript("var x = 1; try { var x = 66; throw 789; } catch( e : Dynamic ) e + x",790);
assertScript("var x = 1; var f = function(x) throw x; try f(55) catch( e : Dynamic ) e + x",56);
assertScript("var i=2; if( true ) --i; i",1);
assertScript("var i=0; if( i++ > 0 ) i=3; i",1);
assertScript("var a = 5/2; a",2.5);
assertScript("{ x = 3; x; }", 3);
assertScript("{ x : 3, y : {} }.x", 3);
assertScript("function bug(){ \n }\nbug().x", null);
assertScript("1 + 2 == 3", true);
assertScript("-2 == 3 - 5", true);
assertScript("var x=-3; x", -3);
assertScript("var a:Array<Dynamic>=[1,2,4]; a[2]", 4, null, true);
assertScript("/**/0", 0);
assertScript("x=1;x*=-2", -2);
}
static function main() {
test("0",0);
test("0xFF", 255);
#if haxe3
test("0xBFFFFFFF",0xBFFFFFFF);
test("0x7FFFFFFF", 0x7FFFFFFF);
#elseif !neko
test("n(0xBFFFFFFF)",0xBFFFFFFF,{ n : haxe.Int32.toNativeInt });
test("n(0x7FFFFFFF)", 0x7FFFFFFF, { n : haxe.Int32.toNativeInt } );
#end
test("-123",-123);
test("- 123",-123);
test("1.546",1.546);
test(".545",.545);
test("'bla'","bla");
test("null",null);
test("true",true);
test("false",false);
test("1 == 2",false);
test("1.3 == 1.3",true);
test("5 > 3",true);
test("0 < 0",false);
test("-1 <= -1",true);
test("1 + 2",3);
test("~545",-546);
test("'abc' + 55","abc55");
test("'abc' + 'de'","abcde");
test("-1 + 2",1);
test("1 / 5",0.2);
test("3 * 2 + 5",11);
test("3 * (2 + 5)",21);
test("3 * 2 // + 5 \n + 6",12);
test("3 /* 2\n */ + 5",8);
test("[55,66,77][1]",66);
test("var a = [55]; a[0] *= 2; a[0]",110);
test("x",55,{ x : 55 });
test("var y = 33; y",33);
test("{ 1; 2; 3; }",3);
test("{ var x = 0; } x",55,{ x : 55 });
test("o.val",55,{ o : { val : 55 } });
test("o.val",null,{ o : {} });
test("var a = 1; a++",1);
test("var a = 1; a++; a",2);
test("var a = 1; ++a",2);
test("var a = 1; a *= 3",3);
test("a = b = 3; a + b",6);
test("add(1,2)",3,{ add : function(x,y) return x + y });
test("a.push(5); a.pop() + a.pop()",8,{ a : [3] });
test("if( true ) 1 else 2",1);
test("if( false ) 1 else 2",2);
test("var t = 0; for( x in [1,2,3] ) t += x; t",6);
test("var a = new Array(); for( x in 0...5 ) a[x] = x; a.join('-')","0-1-2-3-4");
test("(function(a,b) return a + b)(4,5)",9);
test("var y = 0; var add = function(a) y += a; add(5); add(3); y", 8);
test("var a = [1,[2,[3,[4,null]]]]; var t = 0; while( a != null ) { t += a[0]; a = a[1]; }; t",10);
test("var t = 0; for( x in 1...10 ) t += x; t", 45);
#if haxe3
test("var t = 0; for( x in new IntIterator(1,10) ) t +=x; t", 45);
var runner = new TestRunner();
runner.add(new Test());
var succeed = runner.run();
#if sys
Sys.exit(succeed ? 0 : 1);
#elseif flash
flash.system.System.exit(succeed ? 0 : 1);
#else
test("var t = 0; for( x in new IntIter(1,10) ) t +=x; t", 45);
if (!succeed)
throw "failed";
#end
test("var x = 1; try { var x = 66; throw 789; } catch( e : Dynamic ) e + x",790);
test("var x = 1; var f = function(x) throw x; try f(55) catch( e : Dynamic ) e + x",56);
test("var i=2; if( true ) --i; i",1);
test("var i=0; if( i++ > 0 ) i=3; i",1);
test("var a = 5/2; a",2.5);
test("{ x = 3; x; }", 3);
test("{ x : 3, y : {} }.x", 3);
test("function bug(){ \n }\nbug().x", null);
test("1 + 2 == 3", true);
test("-2 == 3 - 5", true);
test("var x=-3; x", -3);
test("var a:Array<Dynamic>=[1,2,4]; a[2]", 4, null, true);
test("/**/0", 0);
test("x=1;x*=-2", -2);
trace("Done");
}
}
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
-cpp bin
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
-cs bin
+2
View File
@@ -0,0 +1,2 @@
-main Test
-dce no
+5
View File
@@ -0,0 +1,5 @@
build-each.hxml
-swf bin/Test.swf
-swf-header 800:600:30:FFFFFF
--flash-strict
-swf-version 9
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
--interp
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
-java bin
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
-js bin/Test.js
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
-neko bin/Test.n
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
-php bin
+2
View File
@@ -0,0 +1,2 @@
build-each.hxml
-python bin/Test.py
+3
View File
@@ -0,0 +1,3 @@
*.exe
*.app
flashplayerdebugger
+77
View File
@@ -0,0 +1,77 @@
import Sys.*;
import sys.FileSystem.*;
import sys.io.File.*;
import haxe.*;
import haxe.io.*;
class Install {
// https://www.adobe.com/support/flashplayer/downloads.html
static var fpDownload(default, never) = switch (systemName()) {
case "Linux":
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/11/flashplayer_11_sa_debug.i386.tar.gz";
case "Mac":
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/19/flashplayer_19_sa_debug.dmg";
case "Windows":
"http://fpdownload.macromedia.com/pub/flashplayer/updaters/19/flashplayer_19_sa_debug.exe";
case _:
throw "unsupported system";
}
// https://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html
static var mmcfg(default, never) = switch (systemName()) {
case "Linux":
Path.join([getEnv("HOME"), "mm.cfg"]);
case "Mac":
"/Library/Application Support/Macromedia/mm.cfg";
case "Windows":
Path.join([getEnv("HOMEDRIVE") + getEnv("HOMEPATH"), "mm.cfg"]);
case _:
throw "unsupported system";
}
// http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7c95.html
static var fpTrust(default, never) = switch (systemName()) {
case "Linux":
Path.join([getEnv("HOME"), ".macromedia/Flash_Player/#Security/FlashPlayerTrust"]);
case "Mac":
"/Library/Application Support/Macromedia/FlashPlayerTrust";
case "Windows":
Path.join([getEnv("SYSTEMROOT"), "system32", "Macromed", "Flash", "FlashPlayerTrust"]);
case _:
throw "unsupported system";
}
static function main() {
switch (systemName()) {
case "Linux":
// Download and unzip flash player
if (command("wget", [fpDownload]) != 0)
throw "failed to download flash player";
if (command("tar", ["-xf", Path.withoutDirectory(fpDownload), "-C", "flash"]) != 0)
throw "failed to extract flash player";
case "Mac":
if (command("brew", ["install", "caskroom/cask/brew-cask"]) != 0)
throw "failed to brew install caskroom/cask/brew-cask";
if (command("brew", ["cask", "install", "flash-player-debugger", "--appdir=flash"]) != 0)
throw "failed to install flash-player-debugger";
case "Windows":
// Download flash player
download(fpDownload, "flash\\flashplayer.exe");
case _:
throw "unsupported system";
}
// Create a configuration file so the trace log is enabled
createDirectory(Path.directory(mmcfg));
saveContent(mmcfg, "ErrorReportingEnable=1\nTraceOutputFileEnable=1");
// Add the current directory as trusted, so exit() can be used
createDirectory(fpTrust);
saveContent(Path.join([fpTrust, "test.cfg"]), getCwd());
}
static function download(url:String, saveAs:String):Void {
var http = new Http(url);
http.onError = function(e) {
throw e;
};
http.customRequest(false, write(saveAs));
}
}
+42
View File
@@ -0,0 +1,42 @@
import Sys.*;
import sys.FileSystem.*;
import sys.io.File.*;
import haxe.io.*;
class Run {
// https://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html
static var flashlog(default, never) = switch (systemName()) {
case "Linux":
Path.join([getEnv("HOME"), ".macromedia/Flash_Player/Logs/flashlog.txt"]);
case "Mac":
Path.join([getEnv("HOME"), "Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt"]);
case "Windows":
Path.join([getEnv("APPDATA"), "Macromedia", "Flash Player", "Logs", "flashlog.txt"]);
case _:
throw "unsupported system";
}
static function main() {
var args = args();
var swf = args[0];
var exitCode = switch (systemName()) {
case "Linux":
// The flash player has some issues with unexplained crashes,
// but if it runs about 8 times, it should succeed one of those...
var c = -1;
for (i in 0...8) {
if ((c = command("xvfb-run", ["flash/flashplayerdebugger", swf])) == 0)
break;
println('retry... (${i+1})');
}
c;
case "Mac":
command("flash/Flash Player Debugger.app/Contents/MacOS/Flash Player Debugger", [fullPath(swf)]);
case "Windows":
command("flash\\flashplayer.exe", [fullPath(swf)]);
case _:
throw "unsupported platform";
}
println(getContent(flashlog));
exit(exitCode);
}
}
+2
View File
@@ -0,0 +1,2 @@
-cp flash
--run Install
+2
View File
@@ -0,0 +1,2 @@
-cp flash
--run Run
+1 -6
View File
@@ -1,6 +1 @@
-swf hscript.swf
-swf-header 800:600:30:FFFFFF
--flash-strict
-swf-version 9
-main Test
-dce no
build-flash.hxml