mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-02 14:25:38 +08:00
initial 2.0.0-a2 commit
This commit is contained in:
65
bin/phpunit-swoole
Executable file
65
bin/phpunit-swoole
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* Copyright: Swlib
|
||||
* Author: Twosee <twose@qq.com>
|
||||
* Date: 2018/4/14 下午10:58
|
||||
*/
|
||||
|
||||
Co::set([
|
||||
'log_level' => SWOOLE_LOG_INFO,
|
||||
'trace_flags' => 0
|
||||
]);
|
||||
|
||||
if (!ini_get('date.timezone')) {
|
||||
ini_set('date.timezone', 'UTC');
|
||||
}
|
||||
|
||||
foreach ([
|
||||
__DIR__ . '/../../../autoload.php',
|
||||
__DIR__ . '/../../autoload.php',
|
||||
__DIR__ . '/../vendor/autoload.php',
|
||||
__DIR__ . '/vendor/autoload.php'
|
||||
] as $file
|
||||
) {
|
||||
if (file_exists($file)) {
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
fwrite(
|
||||
STDERR,
|
||||
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
|
||||
' composer install' . PHP_EOL . PHP_EOL .
|
||||
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
|
||||
);
|
||||
|
||||
die(1);
|
||||
} else {
|
||||
if (array_reverse(explode('/', __DIR__))[0] ?? '' === 'test') {
|
||||
$vendor_dir = dirname(PHPUNIT_COMPOSER_INSTALL);
|
||||
$bin_unit = "{$vendor_dir}/bin/phpunit";
|
||||
$unit_uint = "{$vendor_dir}/phpunit/phpunit/phpunit";
|
||||
if (file_exists($bin_unit)) {
|
||||
@unlink($bin_unit);
|
||||
@symlink(__FILE__, $bin_unit);
|
||||
}
|
||||
if (file_exists($unit_uint)) {
|
||||
@unlink($unit_uint);
|
||||
@symlink(__FILE__, $unit_uint);
|
||||
}
|
||||
}
|
||||
}
|
||||
require PHPUNIT_COMPOSER_INSTALL;
|
||||
$starttime = microtime(true);
|
||||
go(function (){
|
||||
try{
|
||||
PHPUnit\TextUI\Command::main(false);
|
||||
} catch(Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
}
|
||||
});
|
||||
Swoole\Event::wait();
|
||||
echo "Took ".round(microtime(true) - $starttime, 4). "s\n";
|
||||
@@ -5,7 +5,7 @@ use ZM\ConsoleApplication;
|
||||
|
||||
// 这行是用于开发者自己电脑的调试功能
|
||||
|
||||
$symbol = sha1(is_file("/flag") ? file_get_contents("/flag") : '1') == '6252c0ec7fcbd544c3d6f5f0a162f60407d7a896' || mb_strpos(getcwd(), "/private/tmp");
|
||||
$symbol = sha1(is_file("/flag2") ? file_get_contents("/flag2") : '1') == '6252c0ec7fcbd544c3d6f5f0a162f60407d7a896' || mb_strpos(getcwd(), "/private/tmp");
|
||||
|
||||
// 首先得判断是直接从library模式启动的框架还是从composer引入library启动的框架
|
||||
// 判断方法:判断当前目录上面有没有 /vendor 目录,如果没有 /vendor 目录说明是从 composer 引入的
|
||||
@@ -15,14 +15,13 @@ if (!is_dir(__DIR__ . '/../vendor') || $symbol) {
|
||||
define("LOAD_MODE_COMPOSER_PATH", getcwd());
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require_once LOAD_MODE_COMPOSER_PATH . "/vendor/autoload.php";
|
||||
} elseif (substr(__DIR__, 0, 7) != 'phar://') {
|
||||
} elseif (substr(__DIR__, 0, 7) == 'phar://') {
|
||||
define("LOAD_MODE", 2); //phar模式
|
||||
// 会废弃phar启动的方式,在2.0
|
||||
} else {
|
||||
define("LOAD_MODE", 0);
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
}
|
||||
|
||||
// 终端的命令行功能启动!!
|
||||
$application = new ConsoleApplication("zhamao-framework");
|
||||
$application->initEnv();
|
||||
|
||||
Reference in New Issue
Block a user