Skip to content

Commit c0e58c4

Browse files
committed
MQE-2042: Port MFTF Coverage to Jenkins
- Add index.php and test.php files
1 parent 283e94f commit c0e58c4

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

etc/codecoverage/index.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Application entry point
4+
*
5+
* Example - run a particular store or website:
6+
* --------------------------------------------
7+
* require __DIR__ . '/app/bootstrap.php';
8+
* $params = $_SERVER;
9+
* $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website2';
10+
* $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
11+
* $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
12+
* \/** @var \Magento\Framework\App\Http $app *\/
13+
* $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
14+
* $bootstrap->run($app);
15+
* --------------------------------------------
16+
*
17+
* Copyright © Magento, Inc. All rights reserved.
18+
* See COPYING.txt for license details.
19+
*/
20+
21+
try {
22+
require __DIR__ . '/app/bootstrap.php';
23+
} catch (\Exception $e) {
24+
echo <<<HTML
25+
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
26+
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
27+
<h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
28+
Autoload error</h3>
29+
</div>
30+
<p>{$e->getMessage()}</p>
31+
</div>
32+
HTML;
33+
exit(1);
34+
}
35+
36+
//Patch start
37+
$driver = new pcov\Clobber\Driver\PHPUnit6();
38+
$coverage = new \SebastianBergmann\CodeCoverage\CodeCoverage($driver);
39+
$coverage->filter()->addDirectoryToWhitelist("app/code/Magento/*");
40+
$coverage->filter()->removeDirectoryFromWhitelist("app/code/Magento/*/Test");
41+
$testName = "NO_TEST_NAME";
42+
if (file_exists(__DIR__ . '/CURRENT_TEST')) {
43+
$testName = file_get_contents(__DIR__ . '/CURRENT_TEST');
44+
}
45+
$id = !empty($testName) ? $testName : "NO_TEST_NAME";
46+
$coverage->start($id);
47+
//Patch end
48+
49+
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
50+
/** @var \Magento\Framework\App\Http $app */
51+
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
52+
$bootstrap->run($app);
53+
54+
// Patch start
55+
$coverage->stop();
56+
$writer = new \SebastianBergmann\CodeCoverage\Report\PHP();
57+
$writer->process($coverage, '/var/www/html/coverage/reports/' . $id . "_" . md5(mt_rand()) . '.cov');
58+
// Patch end

etc/codecoverage/test.php

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
$test = $_GET['test'] ?? "NO_TEST_SPECIFIED";
3+
file_put_contents('CURRENT_TEST', $test);
4+
echo 'SET CURRENT TEST TO ' . $test;

0 commit comments

Comments
 (0)