1
0
mirror of https://github.com/chylex/Lightning-Tracker.git synced 2025-04-07 11:15:44 +02:00

Add support for Codeception code coverage

This commit is contained in:
chylex 2020-09-21 20:28:08 +02:00
parent 42c517a696
commit 91efd38c3f
9 changed files with 3726 additions and 4 deletions

View File

@ -0,0 +1,18 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test (Cover)" type="CodeceptionConfigurationType" factoryName="Codeception">
<CommandLine workingDirectory="$PROJECT_DIR$" />
<PhpTestRunnerSettings method="" scope="ConfigurationFile" options="--coverage --coverage-xml --coverage-html" />
<method v="2">
<option name="GulpBeforeRunTask" enabled="true">
<node-interpreter>project</node-interpreter>
<node-options />
<gulpfile>$PROJECT_DIR$/build/gulpfile.js</gulpfile>
<tasks>
<task>prepareCoverage</task>
</tasks>
<arguments />
<envs />
</option>
</method>
</configuration>
</component>

View File

@ -1,3 +1,3 @@
<component name="DependencyValidationManager">
<scope name="No Formatting" pattern="file[LightningTracker]:res/~resources/fonts//*||file[LightningTracker]:res/~resources/css/icons.css||file[LightningTracker]:composer.lock" />
<scope name="No Formatting" pattern="file[LightningTracker]:res/~resources/fonts//*||file[LightningTracker]:res/~resources/css/icons.css||file[LightningTracker]:composer.lock||file:build/coverage/composer.lock" />
</component>

View File

@ -0,0 +1,24 @@
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
enabled: true
remote: true
include:
- './*'
exclude:
- 'c3.php'
- 'codeception.yml'
- 'composer.json'
- 'composer.lock'
- '~database/*'
- '~resources/*'
- 'tests/*'
- 'vendor/*'

View File

@ -0,0 +1,6 @@
{
"require-dev": {
"codeception/codeception": "4.1.7",
"codeception/c3": "2.4"
}
}

3634
build/coverage/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

12
build/coverage/index.php Normal file
View File

@ -0,0 +1,12 @@
<?php
/** @noinspection PhpMissingStrictTypesDeclarationInspection */
require __DIR__.'/c3.php';
/** @noinspection ConstantCanBeUsedInspection */
if (version_compare(PHP_VERSION, '7.4', '<')){
die('Lightning Tracker requires PHP 7.4 or newer.');
}
require __DIR__.'/bootstrap.php';
?>

View File

@ -7,6 +7,7 @@ const del = require("del");
const glob = require("glob");
const merge = require("merge-stream");
const childProcess = require("child_process");
const crypto = require("crypto");
const fs = require("fs");
const fse = require("fs-extra");
@ -109,8 +110,12 @@ function taskPrepareTests(cb){
if (fs.existsSync(output)){
for(const file of fs.readdirSync(output)){
if (file !== ".gitignore"){
fs.unlinkSync(path.join(output, file));
if (file !== ".gitignore" && !file.endsWith("coverage.serialized") && !file.endsWith("coverage.xml")){
const fullPath = path.join(output, file);
if (fs.lstatSync(fullPath).isFile()){
fs.unlinkSync(fullPath);
}
}
}
}
@ -118,6 +123,24 @@ function taskPrepareTests(cb){
cb();
}
function taskPrepareCoverage(cb){
const tests = "../tests";
const www = "../server/www";
const wwwtests = www + "/tests";
fse.copySync("./coverage", www);
fs.mkdirSync(wwwtests);
for(const file of glob.sync(tests + "/*.yml")){
fs.copyFileSync(file, wwwtests + "/" + path.basename(file));
}
childProcess.execSync("composer install", { cwd: www });
cb();
}
exports.default = series(taskClean, taskCopy, taskCSS, taskHash);
// noinspection JSUnusedGlobalSymbols
exports.prepareTests = series(taskClean, taskCopy, taskCSS, taskHash, taskPrepareTests);
// noinspection JSUnusedGlobalSymbols
exports.prepareCoverage = series(taskClean, taskCopy, taskCSS, taskHash, taskPrepareTests, taskPrepareCoverage);

View File

@ -8,3 +8,7 @@ actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
enabled: true
remote: true
c3_url: 'http://localhost'

View File

@ -69,8 +69,9 @@ class Acceptance extends Module{
$dir_backup = __DIR__.'/../../../server/www-backup';
$dir_www = __DIR__.'/../../../server/www';
$dir_tmp = $dir_www.'-tmp';
$dir_c3 = $dir_www.'/tests/_output/c3tmp';
if (is_dir($dir_backup)){
if (is_dir($dir_backup) && !is_dir($dir_c3)){
$delete = new RecursiveDirectoryIterator($dir_www, FilesystemIterator::SKIP_DOTS);
foreach(new RecursiveIteratorIterator($delete, RecursiveIteratorIterator::CHILD_FIRST) as $path){