Skip to content

Commit 58c5db3

Browse files
authored
fix: Missing test coverage (#2474)
* feat: Add unit tests coverage (Legacy PHP API) * style: Rename coverage_flags to codecov_flags * fix: Don't send empty reports * Remove includeUncoveredFiles * fix: Change paths to `dd-trace-php/...` * fix: Rename /home/circleci/datadog to dd-trace-php/ * fix: Rename /home/circleci/datadog to ./ * fix: Don't disable xdebug when running coverage ! * fix: syntax * fix: Use un-compiled files when running in coverage mode * fix: Use un-compiled files when running in coverage mode * fix: Use un-compiled files when running in coverage mode * fix: Use un-compiled files when running in coverage mode * fix: Don't include uncovered files * fix: Allow un-compiled runs * fix: Syntax * fix: Web Requests Coverage * fix: Ensure a code coverage ID exists * tests: Skip some tests under coverage mode * fix: Don't install symfony/test-pack * fix: Don't install symfony/test-pack * Revert --no-dev change * fix: Handle RoadrunnerServer * tests: Skip incompatible tests * tests: Skip incompatible tests * tests: Skip incompatible tests * style: Rename tracer-integrations to tracer-php (w/ api) * tests: Run WordPress Coverage on PHP 8.2 * fix: Add Laravel 8.x `.env` file * tests: Remove `.env` * fix: Laravel Tests Failures * Push `.env` file
1 parent 40ea21c commit 58c5db3

File tree

31 files changed

+403
-330
lines changed

31 files changed

+403
-330
lines changed

.circleci/continue_config.yml

Lines changed: 94 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,30 @@ aliases:
123123
name: Build and install extension
124124
command: make sudo install install_ini BUILD_DIR=$(pwd)/tmp/build_extension
125125

126+
- &STEP_CODE_COVERAGE
127+
when:
128+
# codecov uploader only on amd64
129+
condition:
130+
and:
131+
- equal: [ true, << parameters.coverage >> ]
132+
- matches:
133+
pattern: "^[^.]+$"
134+
value: << parameters.resource_class >>
135+
steps:
136+
- run:
137+
name: Merge coverage reports
138+
command: |
139+
make merge_coverage_reports
140+
- run:
141+
name: Install CodeCov Uploader Dependencies
142+
command: |
143+
sudo apt update
144+
sudo apt install -y gpg
145+
- codecov/upload:
146+
file: reports/coverage.xml
147+
upload_name: "PHP<< parameters.php_major_minor >>.<< parameters.make_target >>.dd-trace-php"
148+
flags: << parameters.codecov_flags >>
149+
126150
- &STEP_COMPOSER_CACHE_RESTORE
127151
restore_cache:
128152
<<: *CACHE_COMPOSER_KEY
@@ -775,6 +799,12 @@ jobs:
775799
resource_class:
776800
type: string
777801
default: medium
802+
coverage:
803+
type: boolean
804+
default: false
805+
codecov_flags:
806+
type: string
807+
default: ""
778808
working_directory: ~/datadog
779809
<<: *BARE_DOCKER_MACHINE
780810
steps:
@@ -803,8 +833,10 @@ jobs:
803833
name: Run tests
804834
command: |
805835
set -euo pipefail
836+
<<# parameters.coverage >>unset CI && unset CIRCLECI && export DD_AUTOLOAD_NO_COMPILE=true<</ parameters.coverage >>
806837
make << parameters.make_target >> RUST_DEBUG_BUILD=1 PHPUNIT_OPTS="--log-junit test-results/php-unit/results.xml" 2>&1 | tee /dev/stderr | { ! grep -qe "=== Total [0-9]+ memory leaks detected ==="; }
807838
rm -rf tmp/build_extension/tests/opcache/file_cache/* || true
839+
- <<: *STEP_CODE_COVERAGE
808840
- <<: *STEP_STORE_TEST_RESULTS
809841
- run:
810842
command: |
@@ -1490,6 +1522,9 @@ jobs:
14901522
coverage:
14911523
type: boolean
14921524
default: false
1525+
codecov_flags:
1526+
type: string
1527+
default: ""
14931528
<<: *BARE_DOCKER_MACHINE
14941529
environment:
14951530
COMPOSER_PROCESS_TIMEOUT: 0
@@ -1522,35 +1557,21 @@ jobs:
15221557
- <<: *STEP_COMPOSER_TESTS_UPDATE
15231558
- <<: *STEP_PREPARE_TEST_RESULTS_DIR
15241559
- <<: *STEP_EXPORT_CI_ENV
1525-
- <<: *STEP_DISABLE_XDEBUG
1560+
- when:
1561+
condition:
1562+
equal: [ false, << parameters.coverage >> ]
1563+
steps:
1564+
- <<: *STEP_DISABLE_XDEBUG
15261565
- <<: *STEP_WAIT_MYSQL
15271566
- <<: *STEP_WAIT_REQUEST_REPLAYER
15281567
- <<: *STEP_WAIT_TEST_AGENT
15291568
- run:
15301569
name: Run tests
1531-
command: DD_TRACE_AGENT_TIMEOUT=1000 <<# parameters.disable_runner_distributed_tracing >> DD_DISTRIBUTED_TRACING=false <</ parameters.disable_runner_distributed_tracing >> DD_TRACE_TEST_SAPI=<< parameters.sapi >> make << parameters.make_target >> PHPUNIT_OPTS="--log-junit test-results/php-composer/results.xml"
1532-
- when:
1533-
# codecov uploader only on amd64
1534-
condition:
1535-
and:
1536-
- equal: [ true, << parameters.coverage >> ]
1537-
- matches:
1538-
pattern: "^[^.]+$"
1539-
value: << parameters.resource_class >>
1540-
steps:
1541-
- run:
1542-
name: Merge coverage reports
1543-
command: |
1544-
make merge_coverage_reports
1545-
- run:
1546-
name: Install CodeCov Uploader Dependencies
1547-
command: |
1548-
sudo apt update
1549-
sudo apt install -y gpg
1550-
- codecov/upload:
1551-
file: reports/coverage.xml
1552-
upload_name: "PHP<< parameters.php_major_minor >>.<< parameters.make_target >>.dd-trace-php"
1553-
flags: tracer-integrations
1570+
command: |
1571+
set -euo pipefail
1572+
<<# parameters.coverage >>unset CI && unset CIRCLECI && export DD_AUTOLOAD_NO_COMPILE=true<</ parameters.coverage >>
1573+
DD_TRACE_AGENT_TIMEOUT=1000 <<# parameters.disable_runner_distributed_tracing >> DD_DISTRIBUTED_TRACING=false <</ parameters.disable_runner_distributed_tracing >> DD_TRACE_TEST_SAPI=<< parameters.sapi >> make << parameters.make_target >> PHPUNIT_OPTS="--log-junit test-results/php-composer/results.xml"
1574+
- <<: *STEP_CODE_COVERAGE
15541575
- run:
15551576
command: |
15561577
mkdir -p /tmp/artifacts
@@ -1585,6 +1606,9 @@ jobs:
15851606
coverage:
15861607
type: boolean
15871608
default: false
1609+
codecov_flags:
1610+
type: string
1611+
default: ""
15881612
with_executor:
15891613
type: string
15901614
default: 'with_integrations'
@@ -1620,39 +1644,25 @@ jobs:
16201644
- <<: *STEP_COMPOSER_TESTS_UPDATE
16211645
- <<: *STEP_PREPARE_TEST_RESULTS_DIR
16221646
- <<: *STEP_EXPORT_CI_ENV
1623-
- <<: *STEP_DISABLE_XDEBUG
16241647
- when:
1625-
condition:
1626-
equal: [ "with_integrations", << parameters.with_executor >> ]
1627-
steps:
1628-
- <<: *STEP_WAIT_MYSQL
1648+
condition:
1649+
equal: [ false, << parameters.coverage >> ]
1650+
steps:
1651+
- <<: *STEP_DISABLE_XDEBUG
1652+
- when:
1653+
condition:
1654+
equal: [ "with_integrations", << parameters.with_executor >> ]
1655+
steps:
1656+
- <<: *STEP_WAIT_MYSQL
16291657
- <<: *STEP_WAIT_REQUEST_REPLAYER
16301658
- <<: *STEP_WAIT_TEST_AGENT
16311659
- run:
16321660
name: Run tests
1633-
command: DD_TRACE_AGENT_TIMEOUT=1000 <<# parameters.disable_runner_distributed_tracing >> DD_DISTRIBUTED_TRACING=false <</ parameters.disable_runner_distributed_tracing >> DD_TRACE_TEST_SAPI=<< parameters.sapi >> make << parameters.make_target >> RUST_DEBUG_BUILD=1 PHPUNIT_OPTS="--log-junit test-results/php-composer/results.xml"
1634-
- when:
1635-
# codecov uploader only on amd64
1636-
condition:
1637-
and:
1638-
- equal: [ true, << parameters.coverage >> ]
1639-
- matches:
1640-
pattern: "^[^.]+$"
1641-
value: << parameters.resource_class >>
1642-
steps:
1643-
- run:
1644-
name: Merge coverage reports
1645-
command: |
1646-
make merge_coverage_reports
1647-
- run:
1648-
name: Install CodeCov Uploader Dependencies
1649-
command: |
1650-
sudo apt update
1651-
sudo apt install -y gpg
1652-
- codecov/upload:
1653-
file: reports/coverage.xml
1654-
upload_name: "PHP<< parameters.php_major_minor >>.<< parameters.make_target >>.dd-trace-php"
1655-
flags: tracer-integrations
1661+
command: |
1662+
set -euo pipefail
1663+
<<# parameters.coverage >>unset CI && unset CIRCLECI && export DD_AUTOLOAD_NO_COMPILE=true<</ parameters.coverage >>
1664+
DD_TRACE_AGENT_TIMEOUT=1000 <<# parameters.disable_runner_distributed_tracing >> DD_DISTRIBUTED_TRACING=false <</ parameters.disable_runner_distributed_tracing >> DD_TRACE_TEST_SAPI=<< parameters.sapi >> make << parameters.make_target >> RUST_DEBUG_BUILD=1 PHPUNIT_OPTS="--log-junit test-results/php-composer/results.xml"
1665+
- <<: *STEP_CODE_COVERAGE
16561666
- run:
16571667
command: |
16581668
mkdir -p /tmp/artifacts
@@ -4418,6 +4428,18 @@ workflows:
44184428
- test_internal_api_randomized
44194429
- test_opcache
44204430

4431+
- test:
4432+
requires: [ 'Prepare Code' ]
4433+
coverage: true
4434+
codecov_flags: tracer-php
4435+
matrix:
4436+
parameters:
4437+
php_major_minor:
4438+
- "7.4"
4439+
- "8.2"
4440+
make_target:
4441+
- test_unit_coverage
4442+
44214443
- test:
44224444
requires: [ 'Prepare Code' ]
44234445
matrix:
@@ -4530,29 +4552,30 @@ workflows:
45304552
- '7.1'
45314553
- '7.2'
45324554
- '7.3'
4555+
- '7.4'
4556+
- '8.0'
4557+
- '8.1'
4558+
- '8.2'
4559+
- '8.3'
45334560
make_target:
4561+
- test_auto_instrumentation
45344562
- test_composer
4535-
- test_integration
45364563
- test_distributed_tracing
4537-
- test_auto_instrumentation
4564+
- test_integration
45384565

45394566
- integration:
45404567
requires: [ 'Prepare Code' ]
45414568
resource_class: medium+
45424569
coverage: true
4570+
codecov_flags: tracer-php
45434571
matrix:
45444572
parameters:
45454573
php_major_minor:
45464574
- '7.4'
4547-
- '8.0'
4548-
- '8.1'
45494575
- '8.2'
4550-
- '8.3'
45514576
make_target:
4552-
- test_composer_coverage
45534577
- test_integration_coverage
45544578
- test_distributed_tracing_coverage
4555-
- test_auto_instrumentation_coverage
45564579

45574580
- integration_snapshots:
45584581
requires: [ 'Prepare Code' ]
@@ -4565,6 +4588,11 @@ workflows:
45654588
- '7.1'
45664589
- '7.2'
45674590
- '7.3'
4591+
- '7.4'
4592+
- '8.0'
4593+
- '8.1'
4594+
- '8.2'
4595+
- '8.3'
45684596
make_target:
45694597
- test_web
45704598
- test_integrations
@@ -4574,14 +4602,12 @@ workflows:
45744602
# Due to Symfony OOM during composer update
45754603
resource_class: xlarge
45764604
coverage: true
4605+
codecov_flags: tracer-php
45774606
matrix:
45784607
parameters:
45794608
php_major_minor:
45804609
- '7.4'
4581-
- '8.0'
4582-
- '8.1'
45834610
- '8.2'
4584-
- '8.3'
45854611
make_target:
45864612
- test_web_coverage
45874613
- test_integrations_coverage
@@ -4599,6 +4625,11 @@ workflows:
45994625
- '7.1'
46004626
- '7.2'
46014627
- '7.3'
4628+
- '7.4'
4629+
- '8.0'
4630+
- '8.1'
4631+
- '8.2'
4632+
- '8.3'
46024633
make_target:
46034634
- test_distributed_tracing
46044635

@@ -4629,15 +4660,13 @@ workflows:
46294660
sapi: fpm-fcgi
46304661
disable_runner_distributed_tracing: true
46314662
coverage: true
4663+
codecov_flags: tracer-php
46324664
with_executor: 'with_httpbin_and_request_replayer'
46334665
matrix:
46344666
parameters:
46354667
php_major_minor:
46364668
- '7.4'
4637-
- '8.0'
4638-
- '8.1'
46394669
- '8.2'
4640-
- '8.3'
46414670
make_target:
46424671
- test_distributed_tracing_coverage
46434672

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,8 @@ test: global_test_run_dependencies
10471047

10481048
test_unit: global_test_run_dependencies
10491049
$(call run_tests,--testsuite=unit $(TESTS))
1050+
test_unit_coverage: global_test_run_dependencies
1051+
PHPUNIT_COVERAGE=1 $(MAKE) test_unit
10501052

10511053
test_integration: global_test_run_dependencies
10521054
$(call run_tests,--testsuite=integration $(TESTS))
@@ -1282,7 +1284,7 @@ test_web_symfony_34: global_test_run_dependencies
12821284
test_web_symfony_40: global_test_run_dependencies
12831285
# We hit broken updates in this unmaintained version, so we committed a
12841286
# working composer.lock and we composer install instead of composer update
1285-
$(COMPOSER) --working-dir=tests/Frameworks/Symfony/Version_4_0 install
1287+
$(COMPOSER) --working-dir=tests/Frameworks/Symfony/Version_4_0 install --no-dev
12861288
php tests/Frameworks/Symfony/Version_4_0/bin/console cache:clear --no-warmup --env=prod
12871289
$(call run_tests_debug,tests/Integrations/Symfony/V4_0)
12881290
test_web_symfony_42: global_test_run_dependencies
@@ -1348,7 +1350,7 @@ test_scenario_%:
13481350
$(Q) $(COMPOSER_TESTS) scenario $*
13491351

13501352
merge_coverage_reports:
1351-
$(PHPCOV) merge --clover reports/coverage.xml reports/cov
1353+
php -d memory_limit=-1 $(PHPCOV) merge --clover reports/coverage.xml reports/cov
13521354

13531355
### Api tests ###
13541356
API_TESTS_ROOT := ./tests/api

ext/request_hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void dd_request_init_hook_rinit(void) {
172172

173173
PG(auto_prepend_file) = ZSTR_VAL(hook_path);
174174
if (DDTRACE_G(auto_prepend_file) && DDTRACE_G(auto_prepend_file)[0]) {
175-
LOG(WARN, "Backing up auto_prepend_file '%s'", DDTRACE_G(auto_prepend_file));
175+
LOG(INFO, "Backing up auto_prepend_file '%s'", DDTRACE_G(auto_prepend_file));
176176
}
177177
}
178178

0 commit comments

Comments
 (0)