Skip to content

Commit

Permalink
feat(test): Add built-in ecukes test command (#236)
Browse files Browse the repository at this point in the history
* feat(test): Add built-in ecukes test command

* Make ecukes accept files

* changelog

* Add ecukes test

* Add badge

* fix name and copyright
  • Loading branch information
jcs090218 authored Mar 16, 2024
1 parent 3e8d89f commit 946dd03
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 2 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/test_ecukes.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ test-ert-runner:

test-buttercup:
./test/commands/test/buttercup/run.sh

test-ecukes:
./test/commands/test/ecukes/run.sh
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 31 additions & 0 deletions cmds/test/ecukes.js
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

"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);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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][] 測試。
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion lisp/test/buttercup.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
52 changes: 52 additions & 0 deletions lisp/test/ecukes.el
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion lisp/test/melpazoid.el
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
13 changes: 13 additions & 0 deletions test/commands/test/ecukes/Eask
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions test/commands/test/ecukes/run.sh
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

## Commentary:
#
# Test command `ecukes`
#

set -e

echo "Test command 'ecukes'..."
cd $(dirname "$0")

eask test ecukes
eask test ecukes ./features/foo.feature

0 comments on commit 946dd03

Please sign in to comment.