Skip to content

Commit

Permalink
Disable opcache optimizations during some observer tests
Browse files Browse the repository at this point in the history
Opcache inlines functions that only return a constant. Disable
optimizations to prevent differences in tests where such functions
are used (or rewrite the test to not depend on it).
  • Loading branch information
nikic committed Jan 19, 2021
1 parent f2364f3 commit dd7d829
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions ext/zend_test/tests/observer_retval_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Observer: Retvals are observable that are: IS_CONST
zend_test.observer.enabled=1
zend_test.observer.observe_all=1
zend_test.observer.show_return_value=1
opcache.optimization_level=0
--FILE--
<?php
function foo() {
Expand Down
1 change: 1 addition & 0 deletions ext/zend_test/tests/observer_retval_by_ref_03.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Observer: Retvals by reference are observable that are: IS_VAR, ZEND_RETURNS_FUN
zend_test.observer.enabled=1
zend_test.observer.observe_all=1
zend_test.observer.show_return_value=1
opcache.optimization_level=0
--FILE--
<?php
function getMessage() {
Expand Down
16 changes: 8 additions & 8 deletions ext/zend_test/tests/observer_shutdown_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ register_shutdown_function(function () {
echo 'Shutdown: ' . foo() . PHP_EOL;
});

function bar() {
return 42;
function bar($arg) {
return $arg;
}

function foo() {
bar();
return bar();
bar(41);
return bar(42);
}

echo 'Done: ' . bar() . PHP_EOL;
echo 'Done: ' . bar(40) . PHP_EOL;
?>
--EXPECTF--
<!-- init '%s/observer_shutdown_%d.php' -->
<file '%s/observer_shutdown_%d.php'>
<!-- init bar() -->
<bar>
</bar:42>
Done: 42
</bar:40>
Done: 40
</file '%s/observer_shutdown_%d.php'>
<!-- init {closure}() -->
<{closure}>
<!-- init foo() -->
<foo>
<bar>
</bar:42>
</bar:41>
<bar>
</bar:42>
</foo:42>
Expand Down
16 changes: 8 additions & 8 deletions ext/zend_test/tests/observer_shutdown_02.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ class MyClass
}
}

function bar() {
return 42;
function bar($arg) {
return $arg;
}

function foo() {
bar();
return bar();
bar(41);
return bar(42);
}

$mc = new MyClass();

echo 'Done: ' . bar() . PHP_EOL;
echo 'Done: ' . bar(40) . PHP_EOL;
?>
--EXPECTF--
<!-- init '%s/observer_shutdown_%d.php' -->
<file '%s/observer_shutdown_%d.php'>
<!-- init bar() -->
<bar>
</bar:42>
Done: 42
</bar:40>
Done: 40
</file '%s/observer_shutdown_%d.php'>
<!-- init MyClass::__destruct() -->
<MyClass::__destruct>
<!-- init foo() -->
<foo>
<bar>
</bar:42>
</bar:41>
<bar>
</bar:42>
</foo:42>
Expand Down

0 comments on commit dd7d829

Please sign in to comment.