Skip to content

Commit 6eefb8e

Browse files
committed
feat: Add test command
1 parent 37fd014 commit 6eefb8e

File tree

12 files changed

+299
-70
lines changed

12 files changed

+299
-70
lines changed

.github/workflows/local.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Local
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '**.yml'
9+
- lisp/**
10+
- cmds/**
11+
- src/**
12+
- scripts/**
13+
- test/**
14+
- '**.asd'
15+
pull_request:
16+
branches:
17+
- master
18+
paths-ignore:
19+
- '**.md'
20+
workflow_dispatch:
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
test:
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os: [ubuntu-latest, macos-latest, windows-latest]
33+
34+
steps:
35+
- name: Setup SBCL (Ubuntu)
36+
if: runner.os == 'Linux'
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install sbcl
40+
41+
- name: Setup SBCL (macOS)
42+
if: runner.os == 'macOS'
43+
run: |
44+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
45+
brew install sbcl
46+
47+
- name: Setup SBCL (Windows)
48+
if: runner.os == 'Windows'
49+
uses: crazy-max/ghaction-chocolatey@v3
50+
with:
51+
args: install sbcl
52+
53+
- uses: actions/checkout@v4
54+
55+
- name: Install Quicklisp
56+
run: |
57+
make install-ql
58+
59+
- name: Prepare Qob (Unix)
60+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
61+
run: |
62+
chmod -R 777 ./
63+
.github/scripts/setup-qob
64+
65+
- name: Prepare Qob (Windows)
66+
if: matrix.os == 'windows-latest'
67+
run: .github/scripts/setup-qob.ps1
68+
69+
- name: Testing...
70+
run: |
71+
make command-global

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ install-ql: download-ql
2424

2525
command-global:
2626
./test/commands/global/run.sh
27+
28+
command-local:
29+
./test/commands/local/run.sh

cmds/core/test.lisp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
;;;; cmds/core/test.lisp --- Run system tests
2+
3+
;;; Commentary
4+
;;
5+
;; The `test' command definition.
6+
;;
7+
8+
;;; Code
9+
10+
(defpackage qob-cli/test
11+
(:use cl)
12+
(:export command))
13+
14+
(in-package :qob-cli/test)
15+
16+
(defun options ()
17+
"Options for `test' command."
18+
(list ))
19+
20+
(defun handler (cmd)
21+
"Handler for `test' command."
22+
(qob-cli:call-script "core/test" cmd))
23+
24+
(defun command ()
25+
"The `test' command."
26+
(clingon:make-command
27+
:name "test"
28+
:description "Run system tests"
29+
:options (options)
30+
:handler #'handler))
31+
32+
;;; End of cmds/core/test.lisp

cmds/qob.lisp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
,(qob-cli/load:command)
7272
,(qob-cli/locate:command)
7373
,(qob-cli/status:command)
74+
,(qob-cli/test:command)
7475
,(qob-cli/uninstall:command))))
7576

7677
;;; End of cmds/qob.lisp

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ List out all installed dists.
170170
$ qob [GLOBAL-OPTIONS] dists
171171
```
172172

173+
## 🔍 qob install-dists
174+
175+
Install dists.
176+
177+
```sh
178+
$ qob [GLOBAL-OPTIONS] install-dists [NAMES..]
179+
```
180+
173181
## 🔍 qob search
174182

175183
Search systems from archives.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ $ qob [GLOBAL-OPTIONS] eval [FORM] 。
169169
$ qob [GLOBAL-OPTIONS] dists
170170
```
171171
172+
## 🔍 qob install-dists
173+
174+
安裝 dists.
175+
176+
```sh
177+
$ qob [GLOBAL-OPTIONS] install-dists [NAMES..]
178+
```
179+
172180
## 🔍 qob search
173181
174182
從歸檔中搜尋系統。

lisp/_prepare.lisp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,14 @@ to actually set up the systems."
479479
(asdf:primary-system-name (car asd)))
480480
qob-loaded-asds))
481481

482+
(defun qob-primary-test-system-name ()
483+
"Return the primary test system name."
484+
(let* ((name (qob-primary-system-name))
485+
(name (concatenate 'string name "/tests")))
486+
name))
487+
482488
(defun qob-primary-system-entry ()
483-
"Return the primary system."
489+
"Return the primary system entry."
484490
(let ((name (qob-primary-system-name)))
485491
;; NOTE: Not sure why function `assoc' isn't working here;
486492
;; use some and return the value instead.
@@ -489,11 +495,26 @@ to actually set up the systems."
489495
asd))
490496
qob-loaded-asds)))
491497

498+
(defun qob-primary-test-system-entry ()
499+
"Return the primary test system entry."
500+
(let ((name (qob-primary-test-system-name)))
501+
;; NOTE: Not sure why function `assoc' isn't working here;
502+
;; use some and return the value instead.
503+
(some (lambda (asd)
504+
(when (equal (car asd) name)
505+
asd))
506+
qob-loaded-asds)))
507+
492508
(defun qob-primary-system ()
493509
"Return the primary system."
494510
(let ((name (qob-primary-system-name)))
495511
(asdf:find-system name)))
496512

513+
(defun qob-primary-test-system ()
514+
"Return the primary test system."
515+
(let ((name (qob-primary-test-system-name)))
516+
(asdf:find-system name)))
517+
497518
;; NOTE: Use this as project root?
498519
(defun qob-primary-root ()
499520
"Return the primary system path."

lisp/core/test.lisp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
;;;; lisp/core/test.lisp --- Run system tests
2+
3+
;;; Commentary
4+
;;
5+
;; Command use to run system tests,
6+
;;
7+
;; $ qob test [names..]
8+
;;
9+
10+
;;; Code
11+
12+
(qob-start
13+
(let ((names (qob-args))
14+
(primary-test-system (qob-primary-test-system-entry)))
15+
(cond
16+
;; If specified system(s).
17+
(names
18+
(dolist (name names)
19+
(asdf:test-system name)))
20+
;; Print primary system.
21+
(primary-test-system
22+
(asdf:test-system (car primary-test-system)))
23+
;; Print help.
24+
(t
25+
(qob-help "core/test")))))
26+
27+
;;; End of lisp/core/test.lisp

lisp/help/core/test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
💡 You need to specify the systems you want to test:
3+
4+
$ qob test <system-1> <system-2> ...

lisp/shared.lisp

Lines changed: 71 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,77 +10,79 @@
1010

1111
(defun qob-install-systems (names)
1212
"Install systems by NAMES."
13-
(let* ((silent-p (not (qob-reach-verbosity-p 'debug)))
14-
(total (length names))
15-
(count 1)
16-
(installed 0)
17-
(skipped 0))
18-
(qob-msg "Installing ~A system~A... " total (qob--sinr total "" "s"))
19-
(qob-msg "")
20-
(dolist (name names)
21-
(let* ((system (ql-dist:find-system name))
22-
(installed-system (ignore-errors (asdf:find-system name)))
23-
(version (or (and installed-system
24-
(asdf:component-version installed-system))
25-
;;(slot-value system 'ql-dist:version)
26-
"0"))
27-
(install-p))
28-
(cond (installed-system
29-
(qob-msg " - [~A/~A] Skipping ~A (~A)... already installed ✗"
30-
count total
31-
(qob-ansi-green name)
32-
(qob-ansi-yellow version))
33-
(incf skipped))
34-
(t
35-
(qob-with-progress
36-
(qob-format " - [~A/~A] Installing ~A (~A)... "
37-
count total
38-
(qob-ansi-green name)
39-
(qob-ansi-yellow version))
40-
(qob-with-verbosity
41-
'debug
42-
(setq install-p
43-
(ignore-errors (ql:quickload name :silent silent-p))))
44-
(if install-p "done ✓" "skipped ✗"))
45-
(when install-p
46-
(incf installed)))))
47-
(incf count))
48-
(qob-msg "")
49-
(qob-info "(Total of ~A system~A installed; ~A skipped)" installed
50-
(qob--sinr installed "" "s")
51-
skipped)))
13+
(when names
14+
(let* ((silent-p (not (qob-reach-verbosity-p 'debug)))
15+
(total (length names))
16+
(count 1)
17+
(installed 0)
18+
(skipped 0))
19+
(qob-msg "Installing ~A system~A... " total (qob--sinr total "" "s"))
20+
(qob-msg "")
21+
(dolist (name names)
22+
(let* ((system (ql-dist:find-system name))
23+
(installed-system (ignore-errors (asdf:find-system name)))
24+
(version (or (and installed-system
25+
(asdf:component-version installed-system))
26+
;;(slot-value system 'ql-dist:version)
27+
"0"))
28+
(install-p))
29+
(cond (installed-system
30+
(qob-msg " - [~A/~A] Skipping ~A (~A)... already installed ✗"
31+
count total
32+
(qob-ansi-green name)
33+
(qob-ansi-yellow version))
34+
(incf skipped))
35+
(t
36+
(qob-with-progress
37+
(qob-format " - [~A/~A] Installing ~A (~A)... "
38+
count total
39+
(qob-ansi-green name)
40+
(qob-ansi-yellow version))
41+
(qob-with-verbosity
42+
'debug
43+
(setq install-p
44+
(ignore-errors (ql:quickload name :silent silent-p))))
45+
(if install-p "done ✓" "skipped ✗"))
46+
(when install-p
47+
(incf installed)))))
48+
(incf count))
49+
(qob-msg "")
50+
(qob-info "(Total of ~A system~A installed; ~A skipped)" installed
51+
(qob--sinr installed "" "s")
52+
skipped))))
5253

5354
(defun qob-uninstall-systems (names)
5455
"Uninstall systesm by NAMES."
55-
(let* ((total (length names))
56-
(count 1)
57-
(installed 0)
58-
(skipped 0))
59-
(qob-msg "Uninstalling ~A system~A... " total (qob--sinr total "" "s"))
60-
(qob-msg "")
61-
(dolist (name names)
62-
(let* ((installed-system (ignore-errors (asdf:find-system name)))
63-
(version (or (and installed-system
64-
(asdf:component-version installed-system))
65-
"0")))
66-
(cond ((null installed-system)
67-
(qob-msg " - [~A/~A] Skipping ~A (~A)... not installed ✗"
68-
count total
69-
(qob-ansi-green name)
70-
(qob-ansi-yellow version))
71-
(incf skipped))
72-
(t
73-
(qob-with-progress
74-
(qob-format " - [~A/~A] Uninstalling ~A (~A)... "
75-
count total
76-
(qob-ansi-green name)
77-
(qob-ansi-yellow version))
78-
(qob-with-verbosity 'debug (ql:uninstall name))
79-
"done ✓")
80-
(incf installed))))
81-
(incf count))
82-
(qob-msg "")
83-
(qob-info "(Total of ~A system~A uninstalled; ~A skipped)" installed
84-
(qob--sinr installed "" "s") skipped)))
56+
(when names
57+
(let* ((total (length names))
58+
(count 1)
59+
(installed 0)
60+
(skipped 0))
61+
(qob-msg "Uninstalling ~A system~A... " total (qob--sinr total "" "s"))
62+
(qob-msg "")
63+
(dolist (name names)
64+
(let* ((installed-system (ignore-errors (asdf:find-system name)))
65+
(version (or (and installed-system
66+
(asdf:component-version installed-system))
67+
"0")))
68+
(cond ((null installed-system)
69+
(qob-msg " - [~A/~A] Skipping ~A (~A)... not installed ✗"
70+
count total
71+
(qob-ansi-green name)
72+
(qob-ansi-yellow version))
73+
(incf skipped))
74+
(t
75+
(qob-with-progress
76+
(qob-format " - [~A/~A] Uninstalling ~A (~A)... "
77+
count total
78+
(qob-ansi-green name)
79+
(qob-ansi-yellow version))
80+
(qob-with-verbosity 'debug (ql:uninstall name))
81+
"done ✓")
82+
(incf installed))))
83+
(incf count))
84+
(qob-msg "")
85+
(qob-info "(Total of ~A system~A uninstalled; ~A skipped)" installed
86+
(qob--sinr installed "" "s") skipped))))
8587

8688
;;; End of lisp/shared.lisp

qob-cli.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
(:file "cmds/core/load")
3232
(:file "cmds/core/locate")
3333
(:file "cmds/core/status")
34+
(:file "cmds/core/test")
3435
(:file "cmds/core/uninstall")
3536
(:file "cmds/qob")
3637
;; Program

0 commit comments

Comments
 (0)