Code Monkey home page Code Monkey logo

docker's Introduction

XSpec Docker Image

XSpec is a unit test and behaviour-driven development (BDD) framework for XSLT, XQuery, and Schematron.

This is the Docker image for XSpec v0.5.0.

How to build and run it

Building instructions are relevant until the XSpec Docker image is accepted in Docker Hub.

Clone the repository, go to the directory where the Dockerfile is located, and build the Docker image as follow:

docker build -t xspec:latest .

Run the Docker container with no arguments to check that it works correctly:

docker run xspec

This should output the help:

Saxon script not found, invoking JVM directly instead.

Usage: xspec [-t|-q|-c|-j|-h] filename [coverage]

  filename   the XSpec document
  -t         test an XSLT stylesheet (the default)
  -q         test an XQuery module (mutually exclusive with -t)
  -c         output test coverage report
  -j         output JUnit report
  -h         display this help message
  coverage   deprecated, use -c instead

Now run it with the default tutorial file included in XSpec:

docker run xspec /xspec/tutorial/escape-for-regex.xspec

This should output the following:

Saxon script not found, invoking JVM directly instead.

Creating XSpec Directory at /xspec/tutorial/xspec...

Creating Test Stylesheet...

Running Tests...
Testing with SAXON HE 9.7.0.18
No escaping
Must not be escaped at all
Test simple patterns
..When encountering parentheses
escape them.
..When encountering a whitespace character class
escape the backslash
result should have one more character than source
When processing a list of phrases
All phrase elements should remain
Strings should be escaped and status attributes should be added
      FAILED

Formatting Report...
passed: 5 / pending: 0 / failed: 1 / total: 6
Report available at /xspec/tutorial/xspec/escape-for-regex-result.html
Done.

Passing parameters and accessing reports

In the example above both the XSpec test escape-for-regex.xspec and the report /xspec/tutorial/xspec/escape-for-regex-result.html are stored within the container and are not accessible from the host as the container exits at the end of its execution.

To make the report accessible from the localhost and to pass an XSpec test file stored on the localhost, run it with the -v flag. This allows to map a volume on the localhost with a volume inside the container. For example:

docker run -v /tmp:/input xspec /input/mytest.xspec

where

  • /tmp is the directory on your localhost where mytest.xspec and the relevant XSLT you want to test are stored (in other words /tmp/mytest.xspec must exist on your machine)
  • /input is just a convention to define a volume inside the container (in other words input can be replaced with anything you like)

This runs the XSpec test mytest.xspec inside the Docker container and ends with the message:

...
Report available at /input/xspec/mytest-result.html
Done.

As /input is mapped to /tmp on your localhost, the report is available at /tmp/xspec/mytest-result.html.

IMPORTANT: Make sure that /tmp (or any other directory you want to map with the -v flag) has 777 permissions as XSpec runs as an unprivileged user inside Docker and needs to write and remove temporary files. To change permissions on your local /tmp directory use:

sudo chmod 777 /tmp

Finally, you can pass any additional parameter that it is supported by XSpec. For example, to run an XSpec test for XQuery add -q:

docker run -v /tmp:/input xspec -q /input/mytest.xspec

Limitations

At the moment the report is not able to access the CSS file because the path to /xspec/src/reporter/test-report.css is only available inside the container. Creating a directory /xspec/src/reporter on the local host and copying manually the CSS file from the XSpec project is a workaround to display the report with the CSS formatting until this issue is fixed. A pull request fixing this issue is welcome!

Feedback

Send us your feedback and questions via Google Group Mailing List or by raising an issue. Pull requests are welcome too!

docker's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

docker's Issues

Official Dockerfile Spec References Outdated XSpec and Saxon HE Runtime

Thanks in advance for the wonderful project. Been using it off and on for a few years in previous jobs.

I want to use XSpec in an automation pipeline I noticed the reference build (from 0.5.x range) and the Saxon HE version are very old at this time. Since this is the canonical reference version, can we update it accordingly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.