Integration with Travis - xspec/xspec GitHub Wiki
Travis is a popular Continuous Integration service for testing GitHub hosted projets.
The following example illustrates how to run XSpec tests in a Travis build for a project hosted on GitHub.
-
Create the following
.travis.yml
:before_script: # install XSpec - git clone -b master https://github.com/xspec/xspec.git /tmp/xspec # install Saxon - mkdir -p /tmp/saxon - export SAXON_CP=/tmp/saxon/saxon9he.jar - wget -O "${SAXON_CP}" https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.9.1-7/Saxon-HE-9.9.1-7.jar script: - cd test - echo "execute XSpec unit tests" - ./run-xspec-tests.sh
The commands in
before_script
install XSpec in/tmp/xspec
and the Saxon processor in/tmp/saxon
and set the path to the Saxon. The commands inscript
navigate into thetest
directory and run a shell script that executes all the XSpec test suite. Modify the test directory to the location where your XSpec tests are stored. -
Create the shell script
run-xspec-tests.sh
that runs all the XSpec tests in thetest
directory (modify the path/tmp/xspec/bin/xspec.sh
in the second line if needed):#! /bin/bash for xspecfile in *.xspec; do if /tmp/xspec/bin/xspec.sh -e "${xspecfile}" &> result.log; then echo "OK: ${xspecfile}" else echo "FAILED: ${xspecfile}" echo "---------- result.log" cat result.log echo "----------" exit 1 fi done
This shell script outputs the name of the successful XSpec test executed. If an XSpec fails, the script stops, provides the name of the failing test and output the error message stored in the log file
result.log
.Note that this
run-xspec-tests.sh
is only for illustration purposes. It is very slow. For more serious purposes, consider using Ant. -
Push to your GitHub repository the following files:
.travis.yml
: this must be pushed to the root of the GitHub repository you want to test. You can have different.travis.yml
for different branches.run-xspec-tests.sh
: ideally this should be pushed to the same directory when your XSpec tests are located.- your XSpec tests
Here is an output of a successful build with XSpec tests on Travis: