From 946dd0341352ed688e89de1dc745a3d4fd74bfdc Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Fri, 15 Mar 2024 19:02:37 -0700 Subject: [PATCH] feat(test): Add built-in ecukes test command (#236) * feat(test): Add built-in ecukes test command * Make ecukes accept files * changelog * Add ecukes test * Add badge * fix name and copyright --- .github/workflows/test_ecukes.yml | 54 +++++++++++++++++++ CHANGELOG.md | 1 + Makefile | 3 ++ README.md | 1 + cmds/test/ecukes.js | 31 +++++++++++ .../Commands-and-options/_index.en.md | 9 ++++ .../Commands-and-options/_index.zh-tw.md | 9 ++++ lisp/test/buttercup.el | 5 +- lisp/test/ecukes.el | 52 ++++++++++++++++++ lisp/test/melpazoid.el | 3 +- test/commands/test/ecukes/Eask | 13 +++++ .../commands/test/ecukes/features/foo.feature | 0 .../features/step-definitions/ecukes-steps.el | 0 .../test/ecukes/features/support/env.el | 0 test/commands/test/ecukes/run.sh | 29 ++++++++++ 15 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test_ecukes.yml create mode 100644 cmds/test/ecukes.js create mode 100644 lisp/test/ecukes.el create mode 100644 test/commands/test/ecukes/Eask create mode 100644 test/commands/test/ecukes/features/foo.feature create mode 100644 test/commands/test/ecukes/features/step-definitions/ecukes-steps.el create mode 100644 test/commands/test/ecukes/features/support/env.el create mode 100644 test/commands/test/ecukes/run.sh diff --git a/.github/workflows/test_ecukes.yml b/.github/workflows/test_ecukes.yml new file mode 100644 index 00000000..4a9565d1 --- /dev/null +++ b/.github/workflows/test_ecukes.yml @@ -0,0 +1,54 @@ +name: Test ecukes + +on: + push: + branches: + - master + paths: + - 'eask' + - '**.yml' + - lisp/** + - cmds/** + - src/** + - test/** + pull_request: + branches: + - master + paths-ignore: + - '**.md' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + emacs-version: + - 29.2 + + steps: + - uses: jcs090218/setup-emacs@master + with: + version: ${{ matrix.emacs-version }} + + - uses: actions/checkout@v4 + + - name: Prepare Eask (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + run: | + chmod -R 777 ./ + .github/scripts/setup-eask + + - name: Prepare Eask (Windows) + if: matrix.os == 'windows-latest' + run: .github/scripts/setup-eask.ps1 + + - name: Testing... + run: | + make test-ecukes diff --git a/CHANGELOG.md b/CHANGELOG.md index 088e9d71..ba4b1f2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * fix: Allow initialize in other scopes (#229) * feat: Rename command `check-eask` to `analyze` (#230) * feat(fmt): Add formatters (#232) +* feat(test): Add built-in `ecukes` test command (#236) ## 0.9.x > Released Nov 17, 2023 diff --git a/Makefile b/Makefile index 2987d00d..c87eed4f 100644 --- a/Makefile +++ b/Makefile @@ -65,3 +65,6 @@ test-ert-runner: test-buttercup: ./test/commands/test/buttercup/run.sh + +test-ecukes: + ./test/commands/test/ecukes/run.sh diff --git a/README.md b/README.md index 6158c3da..c968ee4e 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ information.* | Test `ert` command | ✔ | [![Test ert](https://github.com/emacs-eask/cli/actions/workflows/test_ert.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/test_ert.yml) | | Test `ert-runner` command | ✔ | [![Test ert-runner](https://github.com/emacs-eask/cli/actions/workflows/test_ert-runner.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/test_ert-runner.yml) | | Test `buttercup` command | ✔ | [![Test buttercup](https://github.com/emacs-eask/cli/actions/workflows/test_buttercup.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/test_buttercup.yml) | +| Test `ecukes` command | ✔ | [![Test ecukes](https://github.com/emacs-eask/cli/actions/workflows/test_ecukes.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/test_ecukes.yml) | ###### Others diff --git a/cmds/test/ecukes.js b/cmds/test/ecukes.js new file mode 100644 index 00000000..bc9f1b95 --- /dev/null +++ b/cmds/test/ecukes.js @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2024 the Eask authors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +"use strict"; + +exports.command = ['ecukes [files..]']; +exports.desc = 'Run ecukes tests'; +exports.builder = yargs => yargs + .positional( + '[files..]', { + description: 'specify feature files to do ecukes tests', + type: 'array', + }); + +exports.handler = async (argv) => { + await UTIL.e_call(argv, 'test/ecukes', argv.files); +}; diff --git a/docs/content/Getting-Started/Commands-and-options/_index.en.md b/docs/content/Getting-Started/Commands-and-options/_index.en.md index 67e715de..a825efb7 100644 --- a/docs/content/Getting-Started/Commands-and-options/_index.en.md +++ b/docs/content/Getting-Started/Commands-and-options/_index.en.md @@ -795,6 +795,14 @@ Run [buttercup][] tests. $ eask [GLOBAL-OPTIONS] test buttercup ``` +## 🔍 eask test ecukes + +Run [ecukes][] tests. + +```sh +$ eask [GLOBAL-OPTIONS] test ecukes [FILES..] +``` + ## 🔍 eask test melpazoid Run [melpazoid][] tests. @@ -1063,6 +1071,7 @@ Do not use a proxy for any URL matching pattern. [ert]: https://www.gnu.org/software/emacs/manual/html_node/ert/ [ert-runner]: https://github.com/rejeep/ert-runner.el [buttercup]: https://github.com/jorgenschaefer/emacs-buttercup +[ecukes]: https://github.com/ecukes/ecukes [melpazoid]: https://github.com/riscy/melpazoid [elisp-autofmt]: https://codeberg.org/ideasman42/emacs-elisp-autofmt diff --git a/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md b/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md index 69c995f1..c5afaa00 100644 --- a/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md +++ b/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md @@ -782,6 +782,14 @@ $ eask [GLOBAL-OPTIONS] test ert-runner $ eask [GLOBAL-OPTIONS] test buttercup ``` +## 🔍 eask test ecukes + +運行 [ecukes][] 測試。 + +```sh +$ eask [GLOBAL-OPTIONS] test ecukes [FILES..] +``` + ## 🔍 eask test melpazoid 運行 [melpazoid][] 測試。 @@ -1049,6 +1057,7 @@ $ eask --proxy "localhost:8888" [COMMAND] [ert]: https://www.gnu.org/software/emacs/manual/html_node/ert/ [ert-runner]: https://github.com/rejeep/ert-runner.el [buttercup]: https://github.com/jorgenschaefer/emacs-buttercup +[ecukes]: https://github.com/ecukes/ecukes [melpazoid]: https://github.com/riscy/melpazoid [elisp-autofmt]: https://codeberg.org/ideasman42/emacs-elisp-autofmt diff --git a/lisp/test/buttercup.el b/lisp/test/buttercup.el index dab41b7d..658b1401 100644 --- a/lisp/test/buttercup.el +++ b/lisp/test/buttercup.el @@ -15,8 +15,11 @@ nil t)) (eask-start - (eask-with-archives "melpa" + ;; Preparation + (eask-with-archives '("gnu" "melpa") (eask-package-install 'buttercup)) + + ;; Start Testing (require 'buttercup) ;; Propose fix from https://github.com/jorgenschaefer/emacs-buttercup/pull/217 (let ((load-path (cons "." load-path))) diff --git a/lisp/test/ecukes.el b/lisp/test/ecukes.el new file mode 100644 index 00000000..2c096455 --- /dev/null +++ b/lisp/test/ecukes.el @@ -0,0 +1,52 @@ +;;; test/ecukes.el --- Run ecukes tests -*- lexical-binding: t; -*- + +;;; Commentary: +;; +;; Command to run ecukes tests, +;; +;; $ eask ecukes +;; +;; +;; Positionals: +;; +;; [files..] specify feature files to do ecukes tests +;; + +;;; Code: + +(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args))))) + (load (expand-file-name "_prepare.el" + (locate-dominating-file dir "_prepare.el")) + nil t)) + +(defun eask-test-ecukes--run (files) + "Run ecukes on FILES. + +Modified from function `ecukes-cli/run'." + (ecukes-load) + (ecukes-reporter-use ecukes-cli-reporter) + (ecukes-run files)) + +(eask-start + ;; Preparation + (eask-with-archives '("gnu" "melpa") + (eask-package-install 'ecukes)) + + ;; Start Testing + (require 'ecukes) + (let* ((patterns (eask-args)) + (files (eask-expand-file-specs patterns))) + (cond + ;; Files found, do the action! + (files + (eask-test-ecukes--run files)) + ;; Pattern defined, but no file found! + (patterns + (eask-msg "") + (eask-info "(No files match wildcard: %s)" + (mapconcat #'identity patterns " "))) + ;; Run default action. + (t + (ecukes))))) + +;;; test/ecukes.el ends here diff --git a/lisp/test/melpazoid.el b/lisp/test/melpazoid.el index 7ebc5854..eb5bd9d8 100644 --- a/lisp/test/melpazoid.el +++ b/lisp/test/melpazoid.el @@ -33,7 +33,8 @@ (eask-with-archives '("gnu" "melpa") (eask-package-install 'package-lint) (eask-package-install 'pkg-info)) - ;; Start test + + ;; Start Testing (let* ((dirs (or (eask-args) `(,default-directory)))) (cond ;; Files found, do the action! diff --git a/test/commands/test/ecukes/Eask b/test/commands/test/ecukes/Eask new file mode 100644 index 00000000..cc5ec20f --- /dev/null +++ b/test/commands/test/ecukes/Eask @@ -0,0 +1,13 @@ +(package "ecukes" + "0.0.1" + "Test project for command `ecukes'") + +(package-file "ecukes.el") + +(source 'gnu) +(source 'melpa) + +(development + (depends-on "ecukes")) + +(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432 diff --git a/test/commands/test/ecukes/features/foo.feature b/test/commands/test/ecukes/features/foo.feature new file mode 100644 index 00000000..e69de29b diff --git a/test/commands/test/ecukes/features/step-definitions/ecukes-steps.el b/test/commands/test/ecukes/features/step-definitions/ecukes-steps.el new file mode 100644 index 00000000..e69de29b diff --git a/test/commands/test/ecukes/features/support/env.el b/test/commands/test/ecukes/features/support/env.el new file mode 100644 index 00000000..e69de29b diff --git a/test/commands/test/ecukes/run.sh b/test/commands/test/ecukes/run.sh new file mode 100644 index 00000000..d8881829 --- /dev/null +++ b/test/commands/test/ecukes/run.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Copyright (C) 2024 the Eask authors. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +## Commentary: +# +# Test command `ecukes` +# + +set -e + +echo "Test command 'ecukes'..." +cd $(dirname "$0") + +eask test ecukes +eask test ecukes ./features/foo.feature