Przeglądaj źródła

[hl, php] Enable sqlite tests and others (#10597)

* [CI] Include `sqlite.hdll` in hl test build

This way it can be tested

Specify sqlite version for hl

* [CI] Remove bullet from hashlink build

* [CI] Enable more hashlink tests

* [CI] Enable a unicode test for hl and cpp

Test related to #8379

* [CI] Fix php sqlite and socket tests

Enable relevant packages in php config

* [CI] Enable more php tests

Enable php test for #5078

PHP's socket module is now enabled, so we can run socket tests

* [CI] Unspecify libsqlite3-dev version for hl build

Co-authored-by: Simon Krajewski <[email protected]>
tobil4sk 3 lat temu
rodzic
commit
28d6e1142e

+ 1 - 1
Earthfile

@@ -268,7 +268,7 @@ test-environment-cs:
 
 test-environment-hl:
     FROM +test-environment
-    DO +INSTALL_PACKAGES --PACKAGES="cmake ninja-build libturbojpeg-dev libpng-dev zlib1g-dev libvorbis-dev"
+    DO +INSTALL_PACKAGES --PACKAGES="cmake ninja-build libturbojpeg-dev libpng-dev zlib1g-dev libvorbis-dev libsqlite3-dev"
     SAVE IMAGE --cache-hint
 
 test-environment-lua:

+ 5 - 0
tests/PHP.ini

@@ -0,0 +1,5 @@
+; PHP.ini to use on Windows
+extension=php_sqlite3.dll
+extension=php_pdo_sqlite.dll
+extension=php_sockets.dll
+extension=php_mbstring.dll

+ 2 - 3
tests/runci/targets/Hl.hx

@@ -35,7 +35,7 @@ class Hl {
 
 		switch (systemName) {
 			case "Linux":
-				Linux.requireAptPackages(["libpng-dev", "libjpeg-turbo8-dev", "libturbojpeg", "zlib1g-dev", "libvorbis-dev"]);
+				Linux.requireAptPackages(["libpng-dev", "libjpeg-turbo8-dev", "libturbojpeg", "zlib1g-dev", "libvorbis-dev", "libsqlite3-dev"]);
 			case "Mac":
 				runNetworkCommand("brew", ["update", '--preinstall']);
 				runNetworkCommand("brew", ["bundle", '--file=${hlSrc}/Brewfile']);
@@ -47,12 +47,11 @@ class Hl {
 		final generator = systemName == "Windows" ? ["-DCMAKE_SYSTEM_VERSION=10.0.19041.0"] : ["-GNinja"];
 		runCommand("cmake", generator.concat([
 			"-DBUILD_TESTING=OFF",
-			"-DWITH_BULLET=OFF",
 			"-DWITH_DIRECTX=OFF",
 			"-DWITH_FMT=ON",
 			"-DWITH_OPENAL=OFF",
 			"-DWITH_SDL=OFF",
-			"-DWITH_SQLITE=OFF",
+			"-DWITH_SQLITE=ON",
 			"-DWITH_SSL=OFF",
 			"-DWITH_UI=OFF",
 			"-DWITH_UV=OFF",

+ 31 - 6
tests/runci/targets/Php.hx

@@ -3,9 +3,35 @@ package runci.targets;
 import runci.System.*;
 import runci.Config.*;
 
+using haxe.io.Path;
+
 class Php {
 	static final miscPhpDir = getMiscSubDir('php');
 
+	static final windowsPhpIni = cwd + 'PHP.ini';
+
+	static var windowsPhpExtPath(get, null) = null;
+	static function get_windowsPhpExtPath() {
+		if (windowsPhpExtPath != null)
+			return windowsPhpExtPath;
+
+		final phpPath = commandResult("where", ["php"]).stdout;
+		return windowsPhpExtPath = Path.join([phpPath.directory(), "ext"]);
+	}
+
+
+	static function generateArgs(file:String) {
+		if (systemName != "Windows")
+			return [file];
+		return [
+			"-c",
+			windowsPhpIni,
+			"-d",
+			'extension_dir=$windowsPhpExtPath',
+			file
+		];
+	}
+
 	static public function getPhpDependencies() {
 		final phpCmd = commandResult("php", ["-v"]);
 		final phpVerReg = ~/PHP ([0-9]+\.[0-9]+)/i;
@@ -17,8 +43,8 @@ class Php {
 		if (phpCmd.exitCode == 0 && phpVer != null && phpVer >= 7.0) {
 			switch systemName {
 				case "Linux":
-					var phpInfo = commandResult("php", ["-i"]);
-					if(phpInfo.stdout.indexOf("mbstring => enabled") < 0) {
+					var phpInfo = commandResult("php", ["-i"]).stdout;
+					if(phpInfo.indexOf("mbstring => enabled") < 0) {
 						Linux.requireAptPackages(["php-mbstring"]);
 					}
 				case _:
@@ -28,8 +54,7 @@ class Php {
 		}
 		switch systemName {
 			case "Linux":
-				// TODO: install php-sqlite3?
-				Linux.requireAptPackages(["php-cli", "php-mbstring"]);
+				Linux.requireAptPackages(["php-cli", "php-mbstring", "php-sqlite3"]);
 			case "Mac":
 				runNetworkCommand("brew", ["install", "php"]);
 			case "Windows":
@@ -60,14 +85,14 @@ class Php {
 				deleteDirectoryRecursively(binDir);
 
 			runCommand("haxe", ["compile-php.hxml"].concat(prefix).concat(args));
-			runCommand("php", [binDir + "/index.php"]);
+			runCommand("php", generateArgs(binDir + "/index.php"));
 
 			changeDirectory(sysDir);
 			if(isCi())
 				deleteDirectoryRecursively(binDir);
 
 			runCommand("haxe", ["compile-php.hxml"].concat(prefix).concat(args));
-			runSysTest("php", ["bin/php/Main/index.php"]);
+			runSysTest("php", generateArgs(binDir + "/Main/index.php"));
 		}
 	}
 }

+ 1 - 1
tests/sys/run.hxml

@@ -28,7 +28,7 @@ compile.hxml
 # --cmd echo Cpp    && set EXISTS=1 && bin\cpp\Main-debug.exe
 # --cmd echo CS     && set EXISTS=1 && bin\cs\bin\Main-Debug.exe
 # --cmd echo Java   && set EXISTS=1 && java -jar bin\java\Main-Debug.jar
-# --cmd echo Php    && set EXISTS=1 && php bin\php\Main\index.php
+# --cmd echo Php    && set EXISTS=1 && php -c ..\PHP.ini bin\php\Main\index.php
 # --cmd echo Hl     && set EXISTS=1 && hl bin/hl/sys.hl
 # --cmd echo Js     && set EXISTS=1 && node bin/js/sys.js
 # --cmd echo Lua    && set EXISTS=1 && lua bin/lua/sys.lua

+ 3 - 11
tests/sys/src/Main.hx

@@ -14,18 +14,10 @@ class Main {
 		runner.addCase(new io.TestProcess());
 		#end
 		#if !(java || cs || lua || python || eval || js) // Sqlite is not implemented for these targets
-		#if !hl // Idk how to resolve "FATAL ERROR : Failed to load library sqlite.hdll"
-		var testSqlite = #if php Sys.systemName() != 'Windows' #else true #end; //our CI doesn't have sqlite php module
-		if(testSqlite) {
-			runner.addCase(new db.TestSqliteConnection());
-			runner.addCase(new db.TestSqliteResultSet());
-		}
+		runner.addCase(new db.TestSqliteConnection());
+		runner.addCase(new db.TestSqliteResultSet());
 		#end
-		#end
-		#if php
-		if (Sys.systemName() != "Windows")
-		#end
-			runner.addCase(new net.TestSocket());
+		runner.addCase(new net.TestSocket());
 		var report = Report.create(runner);
 		report.displayHeader = AlwaysShowHeader;
 		report.displaySuccessResults = NeverShowSuccessResults;

+ 1 - 3
tests/sys/src/TestUnicode.hx

@@ -319,18 +319,16 @@ class TestUnicode extends utest.Test {
 				// trace
 				assertUEnds(runUtility(["trace", '$i', mode]).stdout, str + endLine);
 				#if !java
-#if (hl || cpp) if (Sys.systemName() != "Windows") { #end // HL and C++ temporarily disabled (#8379)
 				// putEnv + getEnv
 				assertUEquals(runUtility(["putEnv", "HAXE_TEST", '$i', mode, "getEnv", "HAXE_TEST"]).stdout, str + endLine);
 				// putEnv + environment
 				assertUEquals(runUtility(["putEnv", "HAXE_TEST", '$i', mode, "environment", "HAXE_TEST"]).stdout, str + endLine);
-#if (hl || cpp) } #end // HL and C++ temporarily disabled (#8379)
 				#end
 			});
 
 		// args
 		#if !cs // C# behaves like Windows here
-		if (#if (java || eval || hl || cpp) Sys.systemName() != "Windows" #else true #end) {
+		if (#if (java || eval || cpp) Sys.systemName() != "Windows" #else true #end) {
 			// https://stackoverflow.com/questions/7660651/passing-command-line-unicode-argument-to-java-code
 			UnicodeSequences.normalBoth(str -> {
 					assertUEquals(runUtility(["args", str]).stdout, str + endLine);

+ 1 - 1
tests/unit/src/unit/TestArrowFunctions.hx

@@ -87,7 +87,7 @@ class TestArrowFunctions extends Test {
 		f3_1 = (?a:Int, b:String) -> a + b.length;
 		f3_2 = (a:Int, ?b:Int) -> a + b;
 
-		#if !(flash || hl) // Cannot skip not nullable argument
+		#if !flash // Cannot skip not nullable argument
 		f3_1 = function (a=1, b:String) return a + b.length;
 		eq(f3_1("--"),3);
 

+ 1 - 1
tests/unit/src/unit/TestMain.hx

@@ -78,7 +78,7 @@ function main() {
 		new TestNumericCasts(),
 		new TestHashMap(),
 		new TestRest(),
-		#if (!no_http && (!github || !(php && Windows))) new TestHttp(),
+		#if !no_http new TestHttp(),
 		#end
 		#if !no_pattern_matching
 		new TestMatch(),

+ 2 - 2
tests/unit/src/unit/issues/Issue5078.hx

@@ -1,12 +1,12 @@
 package unit.issues;
 
 class Issue5078 extends Test {
-	#if !(js || php || lua)
+	#if !(js || lua)
 	static function getToLower() return "ABC".toLowerCase;
 	#end
 
 	function test() {
-		#if !(js || php || lua)
+		#if !(js || lua)
 		eq(getToLower()(), "abc");
 		#else
 		noAssert();

+ 1 - 1
tests/unit/src/unitstd/EReg.unit.hx

@@ -87,7 +87,7 @@ pos.len == 2;
 ~/a/g.replace("bab", "z") == "bzb";
 ~/a/g.replace("baba", "z") == "bzbz";
 
-#if !(hl && interp) // not allowed in local interpreter, still allowed in hl runtime
+#if !(interp) // not allowed in local interpreter, still allowed in hl runtime
 // replace + $
 ~/href="(.*?)"/.replace('lead href="foo" trail',"$1") == "lead foo trail";
 //~/href="(.*?)"/.replace('lead href="foo" trail',"$2") == "lead $2 trail";

+ 0 - 6
tests/unit/src/unitstd/sys/net/Socket.unit.hx

@@ -1,7 +1,5 @@
 #if sys
 
-#if !(php && Windows)
-
 // bind & listen
 var s = new sys.net.Socket();
 var host = new sys.net.Host("127.0.0.1");
@@ -61,10 +59,6 @@ c.read() == "abc";
 c.close();
 s.close();
 
-#else //!(php && Windows)
-1 == 1;
-#end
-
 #else
 1 == 1;
 #end