README.md 1.79 KB
Newer Older
Jeko's avatar
Jeko committed
1
# Guile Spec - Sugar for SRFI-64 - Inspired by [Speclj](https://github.com/TakaGoto/speclj)
Jeko's avatar
Jeko committed
2

Jeko's avatar
Jeko committed
3
## Try it first !
Jeko's avatar
Jeko committed
4

Jeko's avatar
Jeko committed
5
6
7
Guile Spec is distributed with a `guix.scm` file which can be use to create a virtual environment to host your experiments. You can use it as follow :

```bash
Jeko's avatar
Jeko committed
8
9
$ guix environment --ad-hoc -l guix.scm
$ cd examples
Jeko's avatar
Jeko committed
10
# Run the test and gererate coverage data. Then assert the code is correctly covered.
Jeko's avatar
Jeko committed
11
$ ./run-test-coverage.sh
Jeko's avatar
Jeko committed
12
# Run the tests without coverage
Jeko's avatar
Jeko committed
13
14
$ ./run-tests.sh
```
Jeko's avatar
Jeko committed
15

Jeko's avatar
Jeko committed
16
## Install
Jeko's avatar
Jeko committed
17

Jeko's avatar
Jeko committed
18
Until Guile Spec is available in Guix repository, you can install it using the `guix.scm` file :
19
20
21
22
23
24
25
26
27
```bash
$ guix package --install-from-file=guix.scm
```
Or add these lines to your `~/.config/guix/channels.scm` :
```scheme
(cons (channel
       (name 'jeko)
       (url "git@framagit.org:Jeko/jeko-channel.git"))
      %default-channels)
Jeko's avatar
Jeko committed
28
```
29
30
31
32
And then run :
```bash
$ guix pull
$ guix install guile-spec # or guile2.2-spec for Guile 2.2.7 compatibility
Jeko's avatar
Jeko committed
33
```
Jeko's avatar
Jeko committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
## Usage

Guile Spec provides you with macros and procedures to write tests and read results from the command line.

Put some tests in a file (for example: test-it.scm) :
```scheme
;; First, import the module !
(use-modules (spec))
;; Second, install the runner which handles the test results outputs
(install-runner spec-runner)
;; Third, write some tests
(describe "first-test"
  (it "runs as expected"
    (should "be true" #t)))
```
Run the tests from the command line and see the result :
```bash
$ guile --debug test-it.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/jeko/Workspace/guile-spec/test-it.scm
;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.2/home/jeko/Workspace/guile-spec/test-it.scm.go
first-test
- runs as expected
     PASS should be true
```