Skip to content

Commit 1199e1e

Browse files
committed
FIX do not try to install bash_unit when testing documentation
1 parent c8ba497 commit 1199e1e

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

README.adoc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ You may need to change the behavior of some commands to create conditions for yo
194194

195195
Fails the test and displays an optional message.
196196

197-
```bash
197+
```test
198198
test_can_fail() {
199199
fail "this test failed on purpose"
200200
}
@@ -216,7 +216,7 @@ _assertion_ fails if its evaluation returns a status code different from 0.
216216

217217
In case of failure, the standard output and error of the evaluated _assertion_ is displayed. The optional message is also displayed.
218218

219-
```bash
219+
```test
220220
test_assert_fails() {
221221
assert false "this test failed, obvioulsy"
222222
}
@@ -234,7 +234,7 @@ Running test_assert_succeed... SUCCESS
234234

235235
But you probably want to assert less obvious facts.
236236

237-
```bash
237+
```test
238238
code() {
239239
touch /tmp/the_file
240240
}
@@ -261,7 +261,7 @@ doc:14:test_code_makes_the_file_executable()
261261

262262
It may also be fun to use assert to check for the expected content of a file.
263263

264-
```bash
264+
```test
265265
code() {
266266
echo 'not so cool' > /tmp/the_file
267267
}
@@ -292,7 +292,7 @@ _assertion_ fails if its evaluation returns a status code different from 0.
292292

293293
If the evaluated expression does not fail, then *assert_fail* will fail and display the standard output and error of the evaluated _assertion_. The optional message is also displayed.
294294

295-
```bash
295+
```test
296296
code() {
297297
echo 'not so cool' > /tmp/the_file
298298
}
@@ -328,7 +328,7 @@ It may be useful if you want to distinguish between several error conditions in
328328

329329
In case of failure, the standard output and error of the evaluated _assertion_ is displayed. The optional message is also displayed.
330330

331-
```bash
331+
```test
332332
code() {
333333
exit 23
334334
}
@@ -350,7 +350,7 @@ doc:6:test_code_should_fail_with_code_25()
350350

351351
Asserts for equality of the two strings _expected_ and _actual_.
352352

353-
```bash
353+
```test
354354
test_obvious_inequality_with_assert_equals(){
355355
assert_equals "a string" "another string" "a string should be another string"
356356
}
@@ -374,7 +374,7 @@ doc:2:test_obvious_inequality_with_assert_equals()
374374

375375
Asserts for inequality of the two strings _unexpected_ and _actual_.
376376

377-
```bash
377+
```test
378378
test_obvious_equality_with_assert_not_equals(){
379379
assert_not_equals "a string" "a string" "a string should be different from another string"
380380
}
@@ -400,7 +400,7 @@ Fakes _command_ and replaces it with _replacement code_ (if code is specified) f
400400

401401
For instance:
402402

403-
```bash
403+
```test
404404
fake ps echo hello world
405405
ps
406406
```
@@ -413,7 +413,7 @@ hello world
413413

414414
We can do the same using _stdin_ of fake:
415415

416-
```bash
416+
```test
417417
fake ps << EOF
418418
hello world
419419
EOF
@@ -434,7 +434,7 @@ endif::[]
434434

435435
Here is an exemple, parameterizing fake with its _stdin_ to test that code fails when some process does not run and succeeds otherwise:
436436

437-
```bash
437+
```test
438438
code() {
439439
ps a | grep apache
440440
}
@@ -471,7 +471,7 @@ Running test_code_succeeds_if_apache_runs... SUCCESS
471471

472472
In a previous exemple, we faked _ps_ by specifiyng code inline:
473473

474-
```bash
474+
```test
475475
fake ps echo hello world
476476
ps
477477
```
@@ -482,7 +482,7 @@ hello world
482482

483483
If you need to write more complex code to fake your command, you may abstract this code in a function:
484484

485-
```bash
485+
```test
486486
_ps() {
487487
echo hello world
488488
}
@@ -496,7 +496,7 @@ hello world
496496

497497
Be carefull however that your _ps function is not exported to sub-processes. It means that, depending on how your code under test works, _ps may not be defined in the context where ps will be called. For instance:
498498

499-
```bash
499+
```test
500500
_ps() {
501501
echo hello world
502502
}
@@ -511,7 +511,7 @@ bash: line 1: _ps: command not found
511511

512512
It depends on your code under test but it is safer to just export functions needed by your fake so that they are available in sub-processes:
513513

514-
```bash
514+
```test
515515
_ps() {
516516
echo hello world
517517
}
@@ -541,7 +541,7 @@ For instance, in our previous code that checks apache is running, we have an iss
541541

542542
To do that, the first naive approch would be:
543543

544-
```bash
544+
```test
545545
code() {
546546
ps a | grep apache
547547
}
@@ -581,7 +581,7 @@ With bash, the result code of a pipeline equals the result code of the last comm
581581

582582
An alternative may be to activate bash _pipefail_ option but this may introduce unwanted side effects. We can also simply not output anything in __ps_ so that _grep_ fails:
583583

584-
```bash
584+
```test
585585
code() {
586586
ps a | grep apache
587587
}
@@ -611,7 +611,7 @@ The only correct alternative is for the fake _ps_ to write _FAKE_PARAMS_ in a fi
611611
so that your test can grab them after code execution and assert their value. For instance
612612
by writing to a file:
613613

614-
```bash
614+
```test
615615
code() {
616616
ps a | grep apache
617617
}
@@ -647,7 +647,7 @@ doc:14:test_code_gives_ps_appropriate_parameters()
647647

648648
We can also compact the fake definition:
649649

650-
```bash
650+
```test
651651
code() {
652652
ps a | grep apache
653653
}
@@ -673,7 +673,7 @@ doc:10:test_code_gives_ps_appropriate_parameters()
673673

674674
Finally, we can avoid the _/tmp/fake_params_ temporary file by using _coproc_:
675675

676-
```bash
676+
```test
677677
code() {
678678
ps a | grep apache
679679
}

tests/test_doc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
TEST_PATTERN='```bash|```test'
3+
TEST_PATTERN='```test'
44
OUTPUT_PATTERN='```output'
55
LANG=C.UTF-8
66

0 commit comments

Comments
 (0)