Преглед на файлове

add tests/misc to test compilation with specific compiler configuration

Simon Krajewski преди 11 години
родител
ревизия
7f93d8de1d

+ 1 - 0
.travis.yml

@@ -21,6 +21,7 @@ env:
     - TARGET=neko-sys
     - TARGET=python-sys
     - TARGET=cpp-sys
+    - TARGET=misc
     - TARGET=polygonal-ds
     - TARGET=flambe
     - TARGET=hxtemplo

+ 3 - 0
tests/RunTravis.hx

@@ -351,6 +351,9 @@ class RunTravis {
 				runCommand("haxe", ["compile-python.hxml"]);
 				Sys.setCwd("bin/python");
 				runCommand("python3", ["sys.py", "foo", "12", "a b c\\\\"]);
+			case "misc":
+				Sys.setCwd("../misc");
+				runCommand("haxe", ["compile.hxml"]);
 			case "openfl-samples":
 				getOpenFLDependencies(unitDir);
 

+ 2 - 0
tests/misc/compile.hxml

@@ -0,0 +1,2 @@
+-cp src
+--run Main

+ 16 - 0
tests/misc/projects/Issue2472/Main.hx

@@ -0,0 +1,16 @@
+class Main {
+	static function main() { }
+}
+
+class A<O:{id:String}> {
+	public var o:O;
+	public function new(o:O) {
+		this.o = o;
+	}
+}
+
+class B<O> extends A<O> {
+	public function new(o) {
+		super(o);
+	}
+}

+ 1 - 0
tests/misc/projects/Issue2472/compile-fail.hxml

@@ -0,0 +1 @@
+--run Main

+ 12 - 0
tests/misc/projects/Issue2938/Main.hx

@@ -0,0 +1,12 @@
+import haxe.ds.Vector;
+
+class Main {
+    public static function main() {
+		var width = 9;
+		var slots = new Vector(width);
+		for(i in 0...width){
+			slots[i] = i;
+		}
+		trace(Std.string(slots));
+    }
+}

+ 2 - 0
tests/misc/projects/Issue2938/compile.hxml

@@ -0,0 +1,2 @@
+--no-inline
+--run Main

+ 69 - 0
tests/misc/src/Main.hx

@@ -0,0 +1,69 @@
+import sys.FileSystem;
+import haxe.io.Path;
+import haxe.macro.Expr;
+
+using StringTools;
+
+typedef Result = {
+	count: Int,
+	failures: Int
+}
+
+class Main {
+	static public function main() {
+		var result:Result = compileProjects();
+		Sys.println('Done running ${result.count} tests with ${result.failures} failures');
+		Sys.exit(result.failures);
+	}
+
+	macro static public function compileProjects():ExprOf<Result> {
+		var count = 0;
+		var failures = 0;
+		function browse(dirPath) {
+			var dir = FileSystem.readDirectory(dirPath);
+			for (file in dir) {
+				var path = Path.join([dirPath, file]);
+				if (FileSystem.isDirectory(path)) {
+					browse(path);
+				} else if (file.endsWith(".hxml")) {
+					var old = Sys.getCwd();
+					Sys.setCwd(dirPath);
+					Sys.println('Running haxe $path');
+					var expectFailure = file.endsWith("-fail.hxml");
+					var success = runCommand("haxe", [file], expectFailure);
+					++count;
+					if (!success) {
+						failures++;
+					}
+					Sys.setCwd(old);
+				}
+			}
+		}
+		browse("projects");
+		return macro $v{
+			{
+				count: $v{count},
+				failures: $v{failures}
+			}
+		};
+	}
+
+	static function runCommand(command:String, args:Array<String>, expectFailure:Bool) {
+		var proc = new sys.io.Process(command, args);
+		var exit = proc.exitCode();
+		var success = exit == 0;
+		return switch [success, expectFailure] {
+			case [true, false]:
+				true;
+			case [true, true]:
+				Sys.println("Expected failure, but no failure occured");
+				false;
+			case [false, true]:
+				true;
+			case [false, false]:
+				var stderr = proc.stderr.readAll().toString();
+				Sys.print(stderr);
+				false;
+		}
+	}
+}

+ 53 - 0
tests/misc/testmisc.hxproj

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project version="2">
+  <!-- Output SWF options -->
+  <output>
+    <movie outputType="CustomBuild" />
+    <movie input="" />
+    <movie path="testopt.js" />
+    <movie fps="0" />
+    <movie width="0" />
+    <movie height="0" />
+    <movie version="1" />
+    <movie minorVersion="0" />
+    <movie platform="JavaScript" />
+    <movie background="#FFFFFF" />
+  </output>
+  <!-- Other classes to be compiled into your SWF -->
+  <classpaths>
+    <class path="src" />
+  </classpaths>
+  <!-- Build options -->
+  <build>
+    <option directives="" />
+    <option flashStrict="False" />
+    <option noInlineOnDebug="False" />
+    <option mainClass="Main" />
+    <option enabledebug="False" />
+    <option additional="" />
+  </build>
+  <!-- haxelib libraries -->
+  <haxelib>
+    <!-- example: <library name="..." /> -->
+  </haxelib>
+  <!-- Class files to compile (other referenced classes will automatically be included) -->
+  <compileTargets>
+    <compile path="src\Main.hx" />
+  </compileTargets>
+  <!-- Paths to exclude from the Project Explorer tree -->
+  <hiddenPaths>
+    <hidden path="obj" />
+  </hiddenPaths>
+  <!-- Executed before build -->
+  <preBuildCommand>haxe compile.hxml</preBuildCommand>
+  <!-- Executed after build -->
+  <postBuildCommand alwaysRun="False" />
+  <!-- Other project options -->
+  <options>
+    <option showHiddenPaths="False" />
+    <option testMovie="Custom" />
+    <option testMovieCommand="" />
+  </options>
+  <!-- Plugin storage -->
+  <storage />
+</project>