107 lines
3.7 KiB
PHP
107 lines
3.7 KiB
PHP
<?php
|
|
/*************************************************************
|
|
# 076 License
|
|
|
|
Copyright (c) テクニカル諏訪子
|
|
|
|
Permission is hereby granted to any person obtaining a copy of the software
|
|
Little Beast (the "Software") to use, modify, merge, copy, publish, distribute,
|
|
sublicense, and/or sell copies of the Software, subject to the following conditions:
|
|
|
|
1. **Origin Attribution**:
|
|
- You must not misrepresent the origin of the Software; you must not claim
|
|
you created the original Software.
|
|
- If the Software is used in a product, you must either:
|
|
a. Provide clear attribution in the product's documentation, user interface,
|
|
or other visible areas, **OR**
|
|
b. Pay the original developers a fee they specify in writing.
|
|
2. **Usage Restriction**:
|
|
- The Software, or any derivative works, dependencies, or libraries
|
|
incorporating it, must not be used for censorship or to suppress freedom of
|
|
speech, expression, or creativity. Prohibited uses include, but are not
|
|
limited to:
|
|
- Censorship of so-called "hate speech", visuals, non-mainstream opinions,
|
|
ideas, or objective reality.
|
|
- Tools or systems designed to restrict access to information or
|
|
artistic works.
|
|
3. **Notice Preservation**:
|
|
- This license and the above copyright notice must remain intact in all copies
|
|
of the source code.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
require_once __DIR__.DIRECTORY_SEPARATOR.'/autoload.php';
|
|
define('ROOT', realpath(__DIR__));
|
|
require_once ROOT.'/config/config.php';
|
|
require_once ROOT.'/util.php';
|
|
if (!CURL_ENABLED) define('ACTIVITYPUB_ENABLED', false);
|
|
|
|
mb_internal_encoding('UTF-8');
|
|
header('Content-Type: text/plain; charset=UTF-8');
|
|
|
|
$testDirs = [ROOT.'/src/Site/Test', ROOT.'/src/Std/Test'];
|
|
$testFiles = [];
|
|
foreach ($testDirs as $d) $testFiles[] = glob($d.'/*.php');
|
|
$testFiles = array_merge(...$testFiles);
|
|
|
|
if (empty($testFiles)) {
|
|
echo "テストファイルではありません\n";
|
|
exit(1);
|
|
}
|
|
|
|
echo count($testFiles)."個テストファイルを実行中:\n";
|
|
echo "------------------------------------------------\n";
|
|
|
|
$totalFiles = 0;
|
|
$successFiles = 0;
|
|
$failedFiles = [];
|
|
|
|
foreach ($testFiles as $testFile) {
|
|
$filename = basename($testFile);
|
|
echo "{$filename}のテストを実行中... ";
|
|
|
|
$totalFiles++;
|
|
|
|
try {
|
|
ob_start();
|
|
require $testFile;
|
|
$output = ob_get_clean();
|
|
|
|
echo "完成\n";
|
|
echo $output;
|
|
echo "\n";
|
|
|
|
$successFiles++;
|
|
} catch (\Throwable $e) {
|
|
$output = ob_get_clean();
|
|
if (!empty($output)) {
|
|
echo $output."\n";
|
|
}
|
|
echo "エラー: ".$e->getMessage()."\n";
|
|
echo "ファイル: ".$e->getFile()." (行: ".$e->getLine().")\n\n";
|
|
$failedFiles[] = [
|
|
'file' => $filename,
|
|
'error' => $e->getMessage(),
|
|
'line' => $e->getLine(),
|
|
];
|
|
}
|
|
}
|
|
|
|
echo "\n";
|
|
echo "テスト結果:\n";
|
|
echo "------------------------------------------------\n";
|
|
echo "テストファイル数: {$totalFiles}\n";
|
|
echo "成功: {$successFiles}\n";
|
|
echo "失敗: ".count($failedFiles)."\n";
|
|
|
|
if (!empty($failedFiles)) {
|
|
echo "\n失敗したテストファイル:\n";
|
|
foreach ($failedFiles as $failed) {
|
|
echo "- {$failed['file']} (行: {$failed['line']}): {$failed['error']}\n";
|
|
}
|
|
} |