File: README.md

package info (click to toggle)
clitest 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 532 kB
  • sloc: sh: 1,611; makefile: 24
file content (72 lines) | stat: -rw-r--r-- 1,800 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
60
61
62
63
64
65
66
67
68
69
70
71
72
# clitest Examples

Here's some simple examples to show you how a test file looks like.


## Pure CLI Tests

Take a look at the `.txt` files. They're just like a shell session
snapshot. You have the `$ ` prompt, the command to be executed, and
the results.

```
$ echo "Hello World"
Hello World
$
```

To test these files, just call `clitest` with no options.

```
$ clitest intro.txt
#1	echo "Hello World"
#2	cd /tmp
#3	pwd
#4	cd "$OLDPWD"
OK: 4 of 4 tests passed
$
```

### Easily create your own test files:

1. Go to your terminal
2. Set your prompt accordingly: `PS1='$ '`
3. Type and run the desired commands
4. Copy & paste it all into a text file
5. Done



## Documentation Tests
 
Now take a look at the `.md` files. They're normal Markdown documents
(with titles, paragraphs, code blocks), created to be read by humans
(after HTML conversion).

Inside the code blocks there are examples of command lines and their
results. `clitest` can extract and run these commands for you! Now you
can guarantee that all your examples are correct.

```
$ clitest --prefix tab cut.md
#1	echo "one:two:three:four:five:six" | cut -d : -f 1
#2	echo "one:two:three:four:five:six" | cut -d : -f 4
#3	echo "one:two:three:four:five:six" | cut -d : -f 1,4
#4	echo "one:two:three:four:five:six" | cut -d : -f 4,1
#5	echo "one:two:three:four:five:six" | cut -d : -f 1-4
#6	echo "one:two:three:four:five:six" | cut -d : -f 4-
OK: 6 of 6 tests passed
$
```

Note that since the code blocks in these Markdown documents are
prefixed by a tab, you must use the `--prefix` option.

Even this `README.md` file you're reading is testable. No options
needed, since the code blocks here do not use prefixes.


## Play Around

Run the tests, change the expected output to force a test fail, use
the `--list-run` option, ...