mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 19:28:39 +00:00
Switch from own docker image to standard selenium images
Since the Selenium images are available for download, and downloading them is usually faster than building them from scratch, this makes taking screenshots easier. Furthermore, since the Selenium image is not specific to KaTeX, it could as well be used for other purposes, thus saving space since a single image can be used in multiple projects. This change also deals with the non-determinism in the Lap screenshot: We detect the one known (and accepted) alternate rendering and change the output file name to Lap_alt in this case. So either Lap or Lap_alt gets saved to, and if the image is different from both, then one of these files will show a modification. On the other hand, if it is equal to either of these, then the matching one will get overwritten, showing no change.
This commit is contained in:
@@ -1,29 +1,65 @@
|
||||
### How to generate screenshotter images
|
||||
----------------------------------------
|
||||
# How to generate screenshotter images
|
||||
|
||||
## Automatic generation of screen shots
|
||||
|
||||
Now you too can generate screenshots from your own computer, and (hopefully)
|
||||
have them look mostly the same as the current ones! To start, make a docker
|
||||
image from the included Dockerfile using a command like
|
||||
have them look mostly the same as the current ones! Make sure you have docker
|
||||
installed and running. Also make sure that the development server is running,
|
||||
or start it by running
|
||||
|
||||
docker build --tag=ss .
|
||||
node server.js
|
||||
|
||||
from within this directory (note you need to have docker installed and running
|
||||
for this to work). This will build a docker image with the `ss` tag, which you
|
||||
can then use to run dockers based on it.
|
||||
in the top level directory of the source tree. If all you want is (re)create
|
||||
all the snapshots for all the browsers, then you can do so by running the
|
||||
`screenshotter.sh` script:
|
||||
|
||||
This Dockerfile is set up such that it will run everything and generate all the
|
||||
screenshots when the docker is run, so no interactive input is required. All
|
||||
that you need to do is mount the KaTeX directory you want to test into the
|
||||
`/KaTeX` directory in the docker, and run the `ss` docker, like so:
|
||||
dockers/Screenshotter/screenshotter.sh
|
||||
|
||||
docker run --volume=/your/KaTeX/:/KaTeX ss
|
||||
It will fetch all required selenium docker images, and use them to
|
||||
take screenshots.
|
||||
|
||||
The `--volume=/your/KaTeX:/KaTeX` switch mounts your KaTeX directory into the
|
||||
docker. Note this is a read-write mounting, so the new screenshots will be
|
||||
directly placed into your KaTeX directory.
|
||||
## Manual generation
|
||||
|
||||
Since this docker is very self-contained, there should be no need to do
|
||||
interactive management of the docker, but if you feel the need, you can read the
|
||||
General Docker Help section of the MathJaxFonts docker readme.
|
||||
If you are creating screenshots on a regular basis, you can keep the
|
||||
docker containers with the selenium setups running. Essentially you
|
||||
are encouraged to reproduce the steps from `screenshotter.sh`
|
||||
manually. Example run for Firefox:
|
||||
|
||||
That's it!
|
||||
container=$(docker run -d -P selenium/standalone-firefox:2.46.0)
|
||||
node dockers/Screenshotter/screenshotter.js -b firefox -c ${container}
|
||||
# possibly repeat the above command as often as you need, then eventually
|
||||
docker stop ${container}
|
||||
docker rm ${container}
|
||||
|
||||
## Use without docker
|
||||
|
||||
It is possible to run `screenshotter.js` without the use of Docker:
|
||||
|
||||
npm install selenium-webdriver
|
||||
node dockers/Screenshotter/screenshotter.js
|
||||
|
||||
This will generate screenshots using the Firefox installed on your system.
|
||||
Browsers other than Firefox can be targeted using the `--browser` option.
|
||||
For a complete list of options pass `--help` as an argument to
|
||||
`screenshotter.js`. Using these it should be possible to have the script
|
||||
connect to almost any Selenium web driver you might have access to.
|
||||
|
||||
Note that screenshots taken without Docker are very likely to disagree
|
||||
from the ones stored in the repository, due to different versions of
|
||||
various software components being used. The screenshots taken in this
|
||||
fashion are well suited for visual inspection, but for exact binary
|
||||
comparisons it would be neccessary to carefully set up the environment
|
||||
to match the one used by the Docker approach.
|
||||
|
||||
## Choosing the list of test cases
|
||||
|
||||
Both `screenshotter.js` and `screenshotter.sh` will accept
|
||||
an `--include` option (short `-i`) which can be used to specify
|
||||
a list of test cases to be processed, as a comma separated list.
|
||||
Conversely, the `--exclude` option (short `-x`) can be used
|
||||
to specify a list of cases which are not being processed.
|
||||
|
||||
Examples:
|
||||
|
||||
node dockers/Screenshotter/screenshotter.js -i Sqrt,SqrtRoot
|
||||
dockers/Screenshotter/screenshotter.sh --exclude=GreekLetters
|
||||
|
Reference in New Issue
Block a user