Permalink
Browse files

Code coverage with catch is not functionaly yet, so add tests but mar…

…k them as XFAIL
  • Loading branch information...
derickr committed Sep 8, 2018
1 parent 7d8319f commit 0ad66bde4bcbc8176b16fc03dd6d16d787d8d757
@@ -1,7 +1,8 @@
--TEST--
Test for bug #1034: path coverage [1] (> PHP 7.1, opcache)
Test for bug #1034: path coverage [1] (> PHP 7.1, < PHP 7.3, opcache)
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.1", '>')) echo "skip > PHP 7.1 needed\n"; ?>
<?php if (!version_compare(phpversion(), "7.1", '>')) echo "skip > PHP 7.1, < PHP 7.3 needed\n"; ?>
<?php if (!version_compare(phpversion(), "7.3", '<')) echo "skip > PHP 7.1, < PHP 7.3 needed\n"; ?>
<?php if (!extension_loaded('zend opcache')) echo "skip opcache required\n"; ?>
--FILE--
<?php
@@ -1,7 +1,8 @@
--TEST--
Test for bug #1034: path coverage [1] (> PHP 7.0.12)
Test for bug #1034: path coverage [1] (> PHP 7.0.12, < PHP 7.3)
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.0.12", '>')) echo "skip > PHP 7.0.12 needed\n"; ?>
<?php if (!version_compare(phpversion(), "7.0.12", '>')) echo "skip > PHP 7.0.12, < PHP 7.3 needed\n"; ?>
<?php if (!version_compare(phpversion(), "7.3", '<')) echo "skip > PHP 7.0.12, < PHP 7.3 needed\n"; ?>
<?php if (extension_loaded('zend opcache')) echo "skip opcache should not be loaded\n"; ?>
--FILE--
<?php
@@ -0,0 +1,58 @@
--TEST--
Test for bug #1034: path coverage [1] (> PHP 7.1, < PHP 7.3, opcache)
--XFAIL--
Bug #1519: PHP 7.3 support — CATCH is done differently and code coverage goes wrong
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.1", '>')) echo "skip > PHP 7.1, < PHP 7.3 needed\n"; ?>
<?php if (!version_compare(phpversion(), "7.3", '<')) echo "skip > PHP 7.1, < PHP 7.3 needed\n"; ?>
<?php if (!extension_loaded('zend opcache')) echo "skip opcache required\n"; ?>
--FILE--
<?php
include 'dump-branch-coverage.inc';
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE | XDEBUG_CC_BRANCH_CHECK);
include 'bug01034-001.inc';
xdebug_stop_code_coverage(false);
$c = xdebug_get_code_coverage();
dump_branch_coverage($c);
?>
--EXPECTF--
0 1 2 3
!42
caught
ifelse
- branches
- 00; OP: 00-04; line: 10-12 HIT; out1: 05 X ; out2: 08 HIT
- 05; OP: 05-07; line: 13-13 X ; out1: 12 X
- 08; OP: 08-11; line: 15-16 HIT; out1: EX X
- 12; OP: 12-15; line: 18-19 X ; out1: EX X
- paths
- 0 5 12: X
- 0 8: HIT
loopy
- branches
- 00; OP: 00-04; line: 02-04 HIT; out1: 10 HIT
- 05; OP: 05-09; line: 05-04 HIT; out1: 10 HIT
- 10; OP: 10-12; line: 04-04 HIT; out1: 13 HIT; out2: 05 HIT
- 13; OP: 13-16; line: 07-08 HIT; out1: EX X
- paths
- 0 10 13: HIT
- 0 10 5 10 13: HIT
trycatch
- branches
- 00; OP: 00-07; line: 21-24 HIT; out1: EX X
- 08; OP: 08-08; line: 26-26 HIT; out1: 09 HIT; out2: EX X
- 09; OP: 09-12; line: 27-29 HIT; out1: EX X
- paths
- 0: HIT
- 8 9: HIT
{main}
- branches
- 00; OP: 00-26; line: 02-36 HIT; out1: EX X
- paths
- 0: HIT
@@ -0,0 +1,57 @@
--TEST--
Test for bug #1034: path coverage [1] (>= PHP 7.3)
--XFAIL--
Bug #1519: PHP 7.3 support — CATCH is done differently and code coverage goes wrong
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.3", '>=')) echo "skip >= PHP 7.3\n"; ?>
<?php if (extension_loaded('zend opcache')) echo "skip opcache should not be loaded\n"; ?>
--FILE--
<?php
include 'dump-branch-coverage.inc';
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE | XDEBUG_CC_BRANCH_CHECK);
include 'bug01034-001.inc';
xdebug_stop_code_coverage(false);
$c = xdebug_get_code_coverage();
dump_branch_coverage($c);
?>
--EXPECTF--
0 1 2 3
!42
caught
ifelse
- branches
- 00; OP: 00-04; line: 10-12 HIT; out1: 05 X ; out2: 08 HIT
- 05; OP: 05-07; line: 13-13 X ; out1: 12 X
- 08; OP: 08-11; line: 15-16 HIT; out1: EX X
- 12; OP: 12-15; line: 18-19 X ; out1: EX X
- paths
- 0 5 12: X
- 0 8: HIT
loopy
- branches
- 00; OP: 00-04; line: 02-04 HIT; out1: 11 HIT
- 05; OP: 05-10; line: 05-04 HIT; out1: 11 HIT
- 11; OP: 11-13; line: 04-04 HIT; out1: 14 HIT; out2: 05 HIT
- 14; OP: 14-17; line: 07-08 HIT; out1: EX X
- paths
- 0 11 14: HIT
- 0 11 5 11 14: HIT
trycatch
- branches
- 00; OP: 00-08; line: 21-24 HIT; out1: EX X
- 12; OP: 12-12; line: 26-26 HIT; out1: 13 HIT; out2: EX X
- 13; OP: 13-16; line: 27-29 HIT; out1: EX X
- paths
- 0: HIT
- 12 13: HIT
{main}
- branches
- 00; OP: 00-29; line: 02-36 HIT; out1: EX X
- paths
- 0: HIT
@@ -1,7 +1,8 @@
--TEST--
Test for bug #1034: path coverage [3] (> PHP 7.0.12)
Test for bug #1034: path coverage [3] (> PHP 7.0.12, < PHP 7.3)
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.0.12", '>')) echo "skip > PHP 7.0.12 needed\n"; ?>
<?php if (!version_compare(phpversion(), "7.0.12", '>')) echo "skip > PHP 7.0.12, < PHP 7.3 needed\n"; ?>
<?php if (!version_compare(phpversion(), "7.3", '<')) echo "skip > PHP 7.0.12, < PHP 7.3 needed\n"; ?>
<?php if (extension_loaded('zend opcache')) echo "skip opcache should not be loaded\n"; ?>
--FILE--
<?php
@@ -0,0 +1,61 @@
--TEST--
Test for bug #1034: path coverage [3] (> PHP 7.1, opcache)
--XFAIL--
Bug #1519: PHP 7.3 support — CATCH is done differently and code coverage goes wrong
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.1", '>')) echo "skip > PHP 7.1 needed\n"; ?>
<?php if (!extension_loaded('zend opcache')) echo "skip opcache required\n"; ?>
--FILE--
<?php
include 'dump-branch-coverage.inc';
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE | XDEBUG_CC_BRANCH_CHECK);
include 'bug01034-003.inc';
xdebug_stop_code_coverage(false);
$c = xdebug_get_code_coverage();
dump_branch_coverage($c);
?>
--EXPECTF--
Let's do some stuff!
caught
And do some more
Let's do some stuff!
caught
And do some more
Let's do some stuff!
CAUGHT IN MAIN
trycatch
- branches
- 00; OP: 00-15; line: 06-13 HIT; out1: 16 HIT; out2: 20 HIT
- 16; OP: 16-17; line: 14-14 HIT; out1: 18 HIT; out2: 27 HIT
- 18; OP: 18-19; line: 15-15 HIT; out1: 41 X ; out2: 34 HIT
- 20; OP: 20-26; line: 13-13 HIT; out1: EX X
- 27; OP: 27-33; line: 14-14 HIT; out1: EX X
- 34; OP: 34-40; line: 15-15 HIT; out1: EX X
- 41; OP: 41-43; line: 17-17 X ; out1: 55 X
- 44; OP: 44-44; line: 18-18 HIT; out1: 45 HIT; out2: 48 HIT
- 45; OP: 45-47; line: 19-19 HIT; out1: 55 HIT
- 48; OP: 48-48; line: 20-20 HIT; out1: 49 X ; out2: 52 HIT
- 49; OP: 49-51; line: 21-21 X ; out1: 55 X
- 52; OP: 52-52; line: 22-22 HIT; out1: 53 HIT; out2: EX X
- 53; OP: 53-54; line: 23-26 HIT; out1: 55 HIT
- 55; OP: 55-58; line: 26-27 HIT; out1: EX X
- paths
- 0 16 18 41 55: X
- 0 16 18 34: HIT
- 0 16 27: HIT
- 0 20: HIT
- 44 45 55: HIT
- 44 48 49 55: X
- 44 48 52 53 55: HIT
{main}
- branches
- 00; OP: 00-28; line: 02-37 HIT; out1: EX X
- 29; OP: 29-29; line: 33-33 HIT; out1: 30 HIT; out2: EX X
- 30; OP: 30-32; line: 34-37 HIT; out1: EX X
- paths
- 0: HIT
- 29 30: HIT
@@ -0,0 +1,63 @@
--TEST--
Test for bug #1034: path coverage [3] (>= PHP 7.3)
--XFAIL--
Bug #1519: PHP 7.3 support — CATCH is done differently and code coverage goes wrong
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.3", '>=')) echo "skip >= PHP 7.3\n"; ?>
<?php if (extension_loaded('zend opcache')) echo "skip opcache should not be loaded\n"; ?>
--FILE--
<?php
include 'dump-branch-coverage.inc';
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE | XDEBUG_CC_BRANCH_CHECK);
include 'bug01034-003.inc';
xdebug_stop_code_coverage(false);
$c = xdebug_get_code_coverage();
dump_branch_coverage($c);
?>
--EXPECTF--
Let's do some stuff!
caught
And do some more
Let's do some stuff!
caught
And do some more
Let's do some stuff!
CAUGHT IN MAIN
trycatch
- branches
- 00; OP: 00-16; line: 06-13 HIT; out1: 17 HIT; out2: 22 HIT
- 17; OP: 17-18; line: 14-14 HIT; out1: 19 HIT; out2: 29 HIT
- 19; OP: 19-20; line: 15-15 HIT; out1: 21 X ; out2: 36 HIT
- 21; OP: 21-21; line: 15-15 X ; out1: 43 X
- 22; OP: 22-28; line: 13-13 HIT; out1: EX X
- 29; OP: 29-35; line: 14-14 HIT; out1: EX X
- 36; OP: 36-42; line: 15-15 HIT; out1: EX X
- 43; OP: 43-45; line: 17-17 X ; out1: 57 X
- 46; OP: 46-46; line: 18-18 HIT; out1: 47 HIT; out2: 50 HIT
- 47; OP: 47-49; line: 19-19 HIT; out1: 57 HIT
- 50; OP: 50-50; line: 20-20 HIT; out1: 51 X ; out2: 54 HIT
- 51; OP: 51-53; line: 21-21 X ; out1: 57 X
- 54; OP: 54-54; line: 22-22 HIT; out1: 55 HIT; out2: EX X
- 55; OP: 55-56; line: 23-26 HIT; out1: 57 HIT
- 57; OP: 57-60; line: 26-27 HIT; out1: EX X
- paths
- 0 17 19 21 43 57: X
- 0 17 19 36: HIT
- 0 17 29: HIT
- 0 22: HIT
- 46 47 57: HIT
- 46 50 51 57: X
- 46 50 54 55 57: HIT
{main}
- branches
- 00; OP: 00-30; line: 02-32 HIT; out1: 34 X
- 31; OP: 31-31; line: 33-33 HIT; out1: 32 HIT; out2: EX X
- 32; OP: 32-33; line: 34-37 HIT; out1: 34 HIT
- 34; OP: 34-34; line: 37-37 HIT; out1: EX X
- paths
- 0 34: X
- 31 32 34: HIT
View
@@ -0,0 +1,8 @@
<?php
foreach (['a'] as $item) {
if (false) {
echo "Test\n";
echo "Test\n";
}
}
?>
View
@@ -0,0 +1,29 @@
--TEST--
Test for bug #1530: Code coverage incorrect for last code line in a loop
--XFAIL--
PHP bug #76046: PHP generates "FE_FREE" opcode on the wrong line.
--INI--
xdebug.default_enable=1
xdebug.auto_trace=0
xdebug.auto_profile=0
xdebug.profiler_enable=0
xdebug.overload_var_dump=0
--FILE--
<?php
$file = 'bug01530.inc';
$pathname = stream_resolve_include_path($file);
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
require $pathname;
$coverage = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
print_r($coverage[$pathname]);
?>
--EXPECTF--
Array
(
[2] => 1
[3] => 1
[4] => -1
[5] => -1
[9] => 1
)

0 comments on commit 0ad66bd

Please sign in to comment.