branch: elpa/kotlin-mode commit c504b569aab3d8188619a17b61b4cca899b94df8 Author: taku0 <mxxouy6x3m_git...@tatapa.org> Commit: taku0 <mxxouy6x3m_git...@tatapa.org>
Add scripts to run tests and linters in Docker --- Makefile | 25 ++++++++++--------------- scripts/invoke_cask.sh | 18 ++++++++++++++++++ scripts/run_linter.sh | 19 +++++++++++++++++++ scripts/run_linter_in_docker.sh | 21 +++++++++++++++++++++ scripts/run_test.sh | 16 ++++++++++++++++ scripts/run_test_in_docker.sh | 23 +++++++++++++++++++++++ 6 files changed, 107 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 16a590da24..ab982e7176 100644 --- a/Makefile +++ b/Makefile @@ -48,21 +48,16 @@ clean: test: ## Tests the package. - $(CASK) exec $(EMACS) --batch -q \ - --eval "(add-to-list 'load-path \""$(shell readlink -f .)"\")" \ - --eval "(add-to-list 'load-path \""$(shell readlink -f .)"/test\")" \ - -f batch-byte-compile \ - *.el - cask exec ert-runner -L . -L test + CASK="${CASK}" EMACS="${EMACS}" scripts/run_test.sh + +test_in_docker: +## Tests the package in Docker. + CASK="${CASK}" EMACS="${EMACS}" scripts/run_test_in_docker.sh lint: ## Run linters. - rm -f *.elc - rm -f kotlin-mode-autoloads.el - $(CASK) exec $(EMACS) --batch -Q \ - -l elisp-lint.el \ - --eval '(setq elisp-lint--debug t)' \ - -f elisp-lint-files-batch \ - *.el - rm -f *.elc - rm -f kotlin-mode-autoloads.el + CASK="${CASK}" EMACS="${EMACS}" scripts/run_linter.sh + +lint_in_docker: +## Run linters in Docker. + CASK="${CASK}" EMACS="${EMACS}" scripts/run_linter_in_docker.sh diff --git a/scripts/invoke_cask.sh b/scripts/invoke_cask.sh new file mode 100755 index 0000000000..23b24dbd46 --- /dev/null +++ b/scripts/invoke_cask.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# A little wrapper for Cask. Used in Makefile. +# If ${CASK} is executable, use it. +# Otherwise, download the Cask to .cask/cask if not exists, then execute it. + +if command -v "${CASK}" > /dev/null +then + "${CASK}" "$@" +elif command -v .cask/cask/bin/cask > /dev/null +then + .cask/cask/bin/cask "$@" +else + mkdir -p .cask || exit 1 + git clone --depth 1 https://github.com/cask/cask.git .cask/cask || exit 1 + chmod a+x .cask/cask/bin/cask || exit 1 + .cask/cask/bin/cask "$@" +fi diff --git a/scripts/run_linter.sh b/scripts/run_linter.sh new file mode 100755 index 0000000000..61e55b283c --- /dev/null +++ b/scripts/run_linter.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Run linter. Used in Makefile. + +if ! [ -d ".cask/$(./scripts/invoke_cask.sh eval '(princ emacs-version)')/elpa/elisp-lint-"* ] +then + ./scripts/invoke_cask.sh install || exit 1 +fi + +./scripts/invoke_cask.sh emacs --version || exit 1 +rm -f *.elc test/*.elc || exit 1 +rm -f *-autoloads.el || exit 1 +./scripts/invoke_cask.sh emacs --batch -Q \ + -l elisp-lint.el \ + --eval '(setq elisp-lint--debug t)' \ + -f elisp-lint-files-batch \ + *.el || exit 1 +rm -f *.elc test/*.elc || exit 1 +rm -f *-autoloads.el || exit 1 diff --git a/scripts/run_linter_in_docker.sh b/scripts/run_linter_in_docker.sh new file mode 100755 index 0000000000..44ebf6bc78 --- /dev/null +++ b/scripts/run_linter_in_docker.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Run linter in Docker. Used in Makefile. + +# Cask does't support Emacs 24. +for version in 28 27 26 25 # 24 +do + docker \ + run \ + --rm \ + --volume="$(pwd)":/src \ + --user="$(id -u):$(id -g)" \ + --workdir="/src" \ + --env=ELDEV_DIR=/src/.eldev \ + --env=HOME=/tmp \ + silex/emacs:${version} \ + bash -c "/src/scripts/run_linter.sh" \ + || exit 1 +done + +echo "done" diff --git a/scripts/run_test.sh b/scripts/run_test.sh new file mode 100755 index 0000000000..cc38930d86 --- /dev/null +++ b/scripts/run_test.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Run tests. Used in Makefile. + +if ! [ -d ".cask/$(./scripts/invoke_cask.sh eval '(princ emacs-version)')/elpa/ert-runner-"* ] +then + ./scripts/invoke_cask.sh install || exit 1 +fi + +./scripts/invoke_cask.sh emacs --version || exit 1 +./scripts/invoke_cask.sh emacs --batch -q \ + --eval "(add-to-list 'load-path \"$(readlink -f .)\")" \ + --eval "(add-to-list 'load-path \"$(readlink -f .)/test\")" \ + -f batch-byte-compile \ + *.el test/*.el || exit 1 +./scripts/invoke_cask.sh exec ert-runner -L . -L test diff --git a/scripts/run_test_in_docker.sh b/scripts/run_test_in_docker.sh new file mode 100755 index 0000000000..2e3dc69d03 --- /dev/null +++ b/scripts/run_test_in_docker.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# Run tests in Docker. Used in Makefile. + +# Cask does't support Emacs 24. +for version in 28 27 26 25 # 24 +do + rm -f *.elc test/*.elc + rm -f *-autoloads.el + docker \ + run \ + --rm \ + --volume="$(pwd)":/src \ + --user="$(id -u):$(id -g)" \ + --workdir="/src" \ + --env=ELDEV_DIR=/src/.eldev \ + --env=HOME=/tmp \ + silex/emacs:${version} \ + bash -c "/src/scripts/run_test.sh" \ + || exit 1 +done + +echo "done"