Skip to content

Commit 157db8b

Browse files
authored
feat(generate/test): Add command to setup test files (#243)
* feat(generate/test): Add command to setup test files * Changelog * test: Add generation tests * Add command ensure files * link
1 parent 87b8e5b commit 157db8b

File tree

15 files changed

+451
-36
lines changed

15 files changed

+451
-36
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
2424
* feat(fmt): Add formatters (#232)
2525
* feat(test): Add built-in `ecukes` test command (#236)
2626
* fix: Don't pollute outer programs (#239)
27+
* feat(generate/test): Add commands to setup test files (#243)
2728

2829
## 0.9.x
2930
> Released Nov 17, 2023

cmds/generate/test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright (C) 2024 the Eask authors.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
"use strict";
19+
20+
exports.command = ['test <type>'];
21+
exports.desc = 'Generate test files based on the testing framework';
22+
exports.builder = function (yargs) {
23+
yargs.usage(`${exports.desc}
24+
25+
Usage: eask generate test <type> [options..]`)
26+
.commandDir('./test/')
27+
.demandCommand();
28+
29+
/* XXX: Configure only in the menu. */
30+
if (UTIL.cmd_count() == 2) {
31+
yargs.positional(
32+
'<type>', {
33+
description: 'type of the testing framework',
34+
});
35+
}
36+
}
37+
38+
exports.handler = async (argv) => { };

cmds/generate/test/buttercup.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (C) 2024 the Eask authors.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
"use strict";
19+
20+
exports.command = ['buttercup'];
21+
exports.desc = 'Create a new Buttercup setup for the project';
22+
23+
exports.handler = async (argv) => {
24+
await UTIL.e_call(argv, 'generate/test/buttercup', argv.file);
25+
};

cmds/generate/test/ecukes.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (C) 2024 the Eask authors.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
"use strict";
19+
20+
exports.command = ['ecukes'];
21+
exports.desc = 'Create a new Ecukes setup for the project';
22+
23+
exports.handler = async (argv) => {
24+
await UTIL.e_call(argv, 'generate/test/ecukes', argv.file);
25+
};

cmds/generate/test/ert-runner.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (C) 2024 the Eask authors.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
"use strict";
19+
20+
exports.command = ['ert-runner [names..]'];
21+
exports.desc = 'Create a new test project for the ert-runner';
22+
exports.builder = yargs => yargs
23+
.positional(
24+
'[names..]', {
25+
description: 'specify test names',
26+
type: 'array',
27+
});
28+
29+
exports.handler = async (argv) => {
30+
await UTIL.e_call(argv, 'generate/test/ert-runner', argv.names);
31+
};

cmds/generate/test/ert.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (C) 2024 the Eask authors.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
"use strict";
19+
20+
exports.command = ['ert [names..]'];
21+
exports.desc = 'Create a new test project for the ert tests';
22+
exports.builder = yargs => yargs
23+
.positional(
24+
'[names..]', {
25+
description: 'specify test names',
26+
type: 'array',
27+
});
28+
29+
exports.handler = async (argv) => {
30+
await UTIL.e_call(argv, 'generate/test/ert', argv.names);
31+
};

docs/content/Getting-Started/Commands-and-options/_index.en.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,41 @@ $ eask [GLOBAL-OPTIONS] generate ignore <name>
509509
to generate ignore file.
510510
{{< /hint >}}
511511

512+
## 🔍 eask generate test ert
513+
514+
Create a new test project for the [ert][] tests.
515+
516+
```sh
517+
$ eask [GLOBAL-OPTIONS] generate test ert [NAMES..]
518+
```
519+
520+
## 🔍 eask generate test ert-runner
521+
522+
Create a new test project for the [ert-runner][].
523+
524+
```sh
525+
$ eask [GLOBAL-OPTIONS] generate test ert-runner [NAMES..]
526+
```
527+
528+
## 🔍 eask generate test buttercup
529+
530+
Create a new [Buttercup][] setup for the project.
531+
532+
```sh
533+
$ eask [GLOBAL-OPTIONS] generate test buttercup
534+
```
535+
536+
## 🔍 eask generate test ecukes
537+
538+
Create a new [Ecukes][] setup for the project.
539+
540+
```sh
541+
$ eask [GLOBAL-OPTIONS] generate test ecukes
542+
```
543+
512544
## 🔍 eask generate workflow circle-ci
513545

514-
Generate CircleCI workflow yaml file.
546+
Generate [CircleCI][] workflow yaml file.
515547

516548
The default filename is `config.yml`.
517549

@@ -523,7 +555,7 @@ This will generate the yaml file under `.circleci/`!
523555

524556
## 🔍 eask generate workflow github
525557

526-
Generate GitHub Actions workflow yaml file.
558+
Generate [GitHub Actions][] workflow yaml file.
527559

528560
The default filename is `test.yml`.
529561

@@ -535,7 +567,7 @@ This will generate the yaml file under `.github/workflow/`!
535567

536568
## 🔍 eask generate workflow gitlab
537569

538-
Generate GitLab Runner workflow yaml file.
570+
Generate [GitLab Runner][] workflow yaml file.
539571

540572
The default filename is `.gitlab-ci.yml`.
541573

@@ -545,7 +577,7 @@ $ eask [GLOBAL-OPTIONS] generate workflow gitlab [--file]
545577

546578
## 🔍 eask generate workflow travis-ci
547579

548-
Generate Travis CI workflow yaml file.
580+
Generate [Travis CI][] workflow yaml file.
549581

550582
The default filename is `.travis.yml`.
551583

@@ -559,23 +591,23 @@ Link between this package and a dependency on the local filesystem. A linked
559591
dependency avoids the need to download a dependency from a remote archive. The
560592
package linked to must either have a `Eask`-file or a `-pkg.el`-file.
561593

562-
## 🔍 eask link add <name> <path>
594+
## 🔍 eask link add
563595

564596
Links the given *source* directory into the package directory of this project,
565597
under the given *package* name.
566598

567599
```sh
568-
$ eask [GLOBAL-OPTIONS] link add <name> <path>
600+
$ eask [GLOBAL-OPTIONS] link add <NAME> <PATH>
569601
```
570602

571-
## 🔍 eask link delete [name..]
603+
## 🔍 eask link delete
572604

573605
Deletes the link for the given packages.
574606

575607
Alias: `remove`
576608

577609
```sh
578-
$ eask [GLOBAL-OPTIONS] link delete [names..]
610+
$ eask [GLOBAL-OPTIONS] link delete [NAMES..]
579611
```
580612

581613
## 🔍 eask link list
@@ -1068,6 +1100,11 @@ Do not use a proxy for any URL matching pattern.
10681100
[Eldev]: https://emacs-eldev.github.io/eldev/
10691101
[Keg]: https://github.com/conao3/keg.el
10701102

1103+
[CircleCI]: https://circleci.com/
1104+
[GitHub Actions]: https://github.com/features/actions
1105+
[GitLab Runner]: https://docs.gitlab.com/runner/
1106+
[Travis CI]: https://www.travis-ci.com/
1107+
10711108
[ert]: https://www.gnu.org/software/emacs/manual/html_node/ert/
10721109
[ert-runner]: https://github.com/rejeep/ert-runner.el
10731110
[buttercup]: https://github.com/jorgenschaefer/emacs-buttercup

docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,41 @@ $ eask [GLOBAL-OPTIONS] generate ignore <name>
498498
💡 此命令使用包 [gitignore-templates](https://github.com/xuchunyang/gitignore-templates.el) 生成忽略文件。
499499
{{< /hint >}}
500500

501+
## 🔍 eask generate test ert
502+
503+
[ert][]測試建立一個新的測試項目。
504+
505+
```sh
506+
$ eask [GLOBAL-OPTIONS] generate test ert [NAMES..]
507+
```
508+
509+
## 🔍 eask generate test ert-runner
510+
511+
[ert-runner][] 建立一個新的測試項目。
512+
513+
```sh
514+
$ eask [GLOBAL-OPTIONS] generate test ert-runner [NAMES..]
515+
```
516+
517+
## 🔍 eask generate test buttercup
518+
519+
為專案建立一個新的 [Buttercup][] 設定。
520+
521+
```sh
522+
$ eask [GLOBAL-OPTIONS] generate test buttercup
523+
```
524+
525+
## 🔍 eask generate test ecukes
526+
527+
為專案創建一個新的 [Ecukes][] 設定。
528+
529+
```sh
530+
$ eask [GLOBAL-OPTIONS] generate test ecukes
531+
```
532+
501533
## 🔍 eask generate workflow circle-ci
502534

503-
生成 CircleCI 工作流 yaml 文件。
535+
生成 [CircleCI][] 工作流 yaml 文件。
504536

505537
默認文件名為 `config.yml`
506538

@@ -512,7 +544,7 @@ $ eask [GLOBAL-OPTIONS] generate workflow circle-ci [--file]
512544

513545
## 🔍 eask generate workflow github
514546

515-
生成 GitHub Actions 工作流 yaml 文件。
547+
生成 [GitHub Actions][] 工作流 yaml 文件。
516548

517549
默認文件名為 `test.yml`
518550

@@ -524,7 +556,7 @@ $ eask [GLOBAL-OPTIONS] generate workflow github [--file]
524556

525557
## 🔍 eask generate workflow gitlab
526558

527-
生成 GitLab Runner 工作流程 yaml 文件。
559+
生成 [GitLab Runner][] 工作流程 yaml 文件。
528560

529561
默認文件名為 `.gitlab-ci.yml`
530562

@@ -534,7 +566,7 @@ $ eask [GLOBAL-OPTIONS] generate workflow gitlab [--file]
534566

535567
## 🔍 eask generate workflow travis-ci
536568

537-
生成 Travis CI 工作流 yaml 文件。
569+
生成 [Travis CI][] 工作流 yaml 文件。
538570

539571
默認文件名為 `.travis.yml`
540572

@@ -547,22 +579,22 @@ $ eask [GLOBAL-OPTIONS] generate workflow travis-ci [--file]
547579
此包與本地文件系統的依賴關係之間的鏈接。 鏈接的依賴項避免了從遠程存檔下載依賴項的需要。
548580
鏈接到的包必須有一個 `Eask` 文件或一個 `-pkg.el` 文件。
549581

550-
## 🔍 eask link add <name> <path>
582+
## 🔍 eask link add
551583

552584
將給定的 *source* 目錄鏈接到此項目的包目錄,在給定的 *package* 名稱下。
553585

554586
```sh
555-
$ eask [GLOBAL-OPTIONS] link add <name> <path>
587+
$ eask [GLOBAL-OPTIONS] link add <NAME> <PATH>
556588
```
557589

558-
## 🔍 eask link delete [name..]
590+
## 🔍 eask link delete
559591

560592
刪除給定包的鏈接。
561593

562594
別名: `remove`
563595

564596
```sh
565-
$ eask [GLOBAL-OPTIONS] link delete [names..]
597+
$ eask [GLOBAL-OPTIONS] link delete [NAMES..]
566598
```
567599

568600
## 🔍 eask link list
@@ -1054,6 +1086,11 @@ $ eask --proxy "localhost:8888" [COMMAND]
10541086
[Eldev]: https://emacs-eldev.github.io/eldev/
10551087
[Keg]: https://github.com/conao3/keg.el
10561088

1089+
[CircleCI]: https://circleci.com/
1090+
[GitHub Actions]: https://github.com/features/actions
1091+
[GitLab Runner]: https://docs.gitlab.com/runner/
1092+
[Travis CI]: https://www.travis-ci.com/
1093+
10571094
[ert]: https://www.gnu.org/software/emacs/manual/html_node/ert/
10581095
[ert-runner]: https://github.com/rejeep/ert-runner.el
10591096
[buttercup]: https://github.com/jorgenschaefer/emacs-buttercup

0 commit comments

Comments
 (0)