diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 531d8ea3..ed7a21a3 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -369,8 +369,10 @@ abstract class BuilderBase foreach ($this->getExts() as $ext) { $ext_name = $ext->getDistName(); - $php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n"; - $php .= "assert(extension_loaded('{$ext_name}'));\n\n"; + if (!empty($ext_name)) { + $php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n"; + $php .= "assert(extension_loaded('{$ext_name}'));\n\n"; + } } $php .= "echo '[micro-test-end]';\n"; return $php; diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index b29ebbee..c48c3ef3 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -178,12 +178,17 @@ abstract class UnixBuilderBase extends BuilderBase file_put_contents( SOURCE_PATH . '/hello.exe', file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') . - 'getOption('without-micro-ext-test') ? 'generateMicroExtTests()) ); chmod(SOURCE_PATH . '/hello.exe', 0755); [$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe'); - if ($ret !== 0 || trim($out = implode('', $output2)) !== 'hello') { - throw new RuntimeException('micro failed sanity check, ret[' . $ret . '], out[' . ($out ?? 'NULL') . ']'); + $raw_out = trim(implode('', $output2)); + $condition[0] = $ret === 0; + $condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]'); + foreach ($condition as $k => $v) { + if (!$v) { + throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]"); + } } } } diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 24b54967..6da15b11 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -261,7 +261,7 @@ class WindowsBuilder extends BuilderBase file_put_contents( SOURCE_PATH . '\hello.exe', file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') . - ($this->getOption('with-micro-ext-test') ? $this->generateMicroExtTests() : 'getOption('without-micro-ext-test') ? 'generateMicroExtTests()) ); chmod(SOURCE_PATH . '\hello.exe', 0755); [$ret, $output2] = cmd()->execWithResult(SOURCE_PATH . '\hello.exe'); diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 9e90cc4c..fa5e40b6 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -36,7 +36,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); - $this->addOption('with-micro-ext-test', null, null, 'Enable phpmicro with extension test code'); + $this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code'); } public function handle(): int