| 1 | #!/bin/sh |
| 2 | # Loads the editor support, headless, on each example: the file must be |
| 3 | # taken for raz, coloured without error, and indented again exactly as |
| 4 | # it is written; and test/editors/Colours.raz must be coloured as |
| 5 | # Colours.expect says. Prints one line per failure; quiet if the editor |
| 6 | # is missing. |
| 7 | |
| 8 | fail=0 |
| 9 | if command -v vim >/dev/null; then |
| 10 | for f in examples/*.raz; do |
| 11 | vim -Nu NONE -i NONE -es \ |
| 12 | -c 'set rtp^=editor/vim' -c 'filetype plugin indent on' -c 'syntax on' \ |
| 13 | -c "edit $f" \ |
| 14 | -c 'if &filetype !=# "raz" || &shiftwidth != 4 | cquit | endif' \ |
| 15 | -c 'let before = getline(1, "$")' -c 'normal! gg=G' \ |
| 16 | -c 'if getline(1, "$") != before | cquit | endif' -c 'qall!' \ |
| 17 | || { echo "FAIL vim on $f"; fail=1; } |
| 18 | done |
| 19 | vim -Nu NONE -i NONE -es -c 'set rtp^=editor/vim' -c 'filetype plugin indent on' \ |
| 20 | -c 'syntax on' -c 'edit test/editors/Colours.raz' -S test/editors/colours.vim \ |
| 21 | || { echo "FAIL vim colours"; fail=1; } |
| 22 | fi |
| 23 | if command -v emacs >/dev/null; then |
| 24 | for f in examples/*.raz; do |
| 25 | emacs -Q --batch -l editor/emacs/raz-mode.el --eval " |
| 26 | (progn |
| 27 | (find-file \"$f\") |
| 28 | (unless (eq major-mode 'raz-mode) (kill-emacs 1)) |
| 29 | (font-lock-ensure) |
| 30 | (let ((before (buffer-string))) |
| 31 | (indent-region (point-min) (point-max)) |
| 32 | (unless (string= before (buffer-string)) (kill-emacs 2))))" \ |
| 33 | 2>/dev/null || { echo "FAIL emacs on $f"; fail=1; } |
| 34 | done |
| 35 | emacs -Q --batch -l editor/emacs/raz-mode.el -l test/editors/colours.el 2>/dev/null \ |
| 36 | || { echo "FAIL emacs colours"; fail=1; } |
| 37 | fi |
| 38 | exit $fail |