Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | #!/bin/bash |
2 | set -ex | |
3 | ||
4 | ## Setup a test site based on source code in the Jenkins workspace | |
5 | ## and run the test suite. | |
6 | ## | |
7 | ## To configure a Jenkins job which runs tests and produces code-coverage, | |
8 | ## put something like this in the job configuration: | |
9 | ## | |
10 | ## [ -d "${WORKSPACE}/build" ] && rm -rf "${WORKSPACE}/build" | |
11 | ## mkdir -p "${WORKSPACE}/build" "${WORKSPACE}/build/CodeCoverage" | |
12 | ## ${WORKSPACE}/civicrm/tools/scripts/phpunit-jenkins \ | |
13 | ## --tap \ | |
14 | ## --coverage-clover "${WORKSPACE}/build/CodeCoverage/clover.xml" \ | |
15 | ## --coverage-html "${WORKSPACE}/build/CodeCoverage/" \ | |
16 | ## --log-junit "${WORKSPACE}/build/junit.xml" \ | |
17 | ## CRM_AllTests | |
18 | ## | |
19 | ## To configure a Jenkins job which run tests but omits code-coverage: | |
20 | ## | |
21 | ## [ -d "${WORKSPACE}/build" ] && rm -rf "${WORKSPACE}/build" | |
22 | ## mkdir -p "${WORKSPACE}/build" | |
23 | ## ${WORKSPACE}/civicrm/tools/scripts/phpunit-jenkins \ | |
24 | ## --tap \ | |
25 | ## --log-junit "${WORKSPACE}/build/junit.xml" \ | |
26 | ## CRM_AllTests | |
bcd9e9f5 | 27 | ## |
6a488035 TO |
28 | |
29 | if [ -z "$EXECUTOR_NUMBER" -o -z "$WORKSPACE" ]; then | |
30 | echo "This script requires the following environment variables:" | |
31 | echo "EXECUTOR_NUMBER" | |
32 | echo "WORKSPACE" | |
33 | exit 1 | |
34 | fi | |
35 | ||
36 | ## Configuration | |
37 | OUTPUT="${WORKSPACE}/build" | |
38 | DRUPAL_ROOT="/var/www/drupal" | |
39 | SITE_URL="jenkins-${EXECUTOR_NUMBER}.localhost" | |
40 | SITE_DB="jenkins_${EXECUTOR_NUMBER}" | |
41 | export CIVICRM_LOCALES=en_US,fr_FR | |
42 | ||
43 | ## Prepare workspace | |
44 | bash "${WORKSPACE}/civicrm/tools/scripts/mk-drupal-test-site" "${SITE_URL}" "${SITE_DB}" "${DRUPAL_ROOT}" "${WORKSPACE}/civicrm/" | |
45 | ||
46 | ## Run tests | |
47 | pushd "${DRUPAL_ROOT}/sites/${SITE_URL}/modules/civicrm/tools" | |
48 | ./scripts/phpunit "$@" | |
49 | # --process-isolation \ | |
50 | popd |