Skip to content

Commit

Permalink
feat: automate profiling test (#15)
Browse files Browse the repository at this point in the history
* add profiling test

* add profiling test

* config DDEV webroot

---------

Co-authored-by: tyler36 <[email protected]>
  • Loading branch information
tyler36 and tyler36 authored Nov 10, 2023
1 parent 46d9893 commit 24702e5
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ health_checks() {
ddev exec "curl -s xhgui:80" | grep "XHGui - Run list"
}

# This tests the collector function works.
collector_checks() {
# Turn on the collector
ddev xhprof
# Ensure there's no profiling data link
ddev exec "curl -s xhgui:80" | grep -v '<a href="/?server_name=web">'

# Profile site
ddev exec "curl -s web:80" | grep "Demo website"
sleep 5
# Ensure there a profiling data link
ddev exec "curl -s xhgui:80" | grep '<a href="/?server_name=web">'
}

@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR}
Expand All @@ -45,3 +59,26 @@ health_checks() {
# Check service works
health_checks
}

@test "a site can be profiled" {
set -eu -o pipefail
cd ${TESTDIR}

# Create test site
echo "# Create a demo website at ${TESTDIR}" >&3
ddev composer require perftools/php-profiler
ddev composer install
ddev config --docroot=public --create-docroot
echo "<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once '/mnt/ddev_config/xhgui/collector/xhgui.collector.php';
echo 'Demo website';" >${TESTDIR}/public/index.php

echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev restart

# Check service works
health_checks
collector_checks
}

0 comments on commit 24702e5

Please sign in to comment.