1
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
1 # Bricolage
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
2
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
3 Bricolage is an ultimately minimal testing library for UNIX Shell. It follows the idea of klud.js and gambiarra.lua
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
4
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
5 ## Usage
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
6
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
7 # include b.sh
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
8 . b.sh
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
9
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
10 # optionally define pass/fail handlers
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
11 pass() {
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
12 echo "PASS $*"
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
13 }
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
14
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
15 fail() {
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
16 echo "FAIL $*"
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
17 }
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
18
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
19 # write your test functions
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
20 mytest() {
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
21 # inside use test assertions
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
22 ok 1 -eq 1
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
23 ok $FOO = "somevalue"
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
24 # mock/spy some commands
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
25 spy ls
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
26 # give fake command output
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
27 echo "file.txt" > $T/spy.ls
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
28 # use fake ls
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
29 ls /some/dir
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
30 # ensure that argument was passed correctly
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
31 ok $(cat $T/spy.ls.args) = "/some/dir"
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
32 # ensure that command return expected output
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
33 ok $(cat $T/spy.ls.stdout) = "file.txt"
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
34 }
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
35
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
36 # run your tests
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
37 bricolage mytest
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
38
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
39 # cleanup
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
40 rm -r $T
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
41
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
42 ## License
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
43
|
Serge A. Zaitsev <zaitsev.serge@gmail.com>
parents:
diff
changeset
|
44 Distributed under MIT license
|
3
|
45
|
|
46 ## Reference
|
|
47
|
|
48 - [Ultimately minimal unit testing][blog], an introduction of Bricolage's philosophy,
|
|
49 written by its author.
|
|
50 - [bitbucket.org/zserge/bricolage][bb], the original code repository,
|
|
51 404 after BitBucket sunsetting Mercurial hosting.
|
|
52
|
|
53 [blog]: https://zserge.com/posts/minimal-testing/
|
|
54 [bb]: http://bitbucket.org/zserge/bricolage
|
|
55
|
|
56 ## License
|
|
57
|
|
58 Distributed under MIT license
|