File: test-more.swim

package info (click to toggle)
git-subrepo 0.4.9-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,552 kB
  • sloc: sh: 7,074; makefile: 273; perl: 226
file content (94 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (2)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Test::More
==========

TAP Testing for Bash

<badge travis ingydotnet/test-more-bash>

= Synopsis

Write a test file like this. Maybe call it `test/test.t`:

  #!/usr/bin/env bash

  TEST_MORE_PATH="/path/to/test-more-bash"
  BASHLIB="`
      find $TEST_MORE_PATH -type d |
      grep -E '/(bin|lib)$' |
      xargs -n1 printf "%s:"`"
  PATH="$BASHLIB$PATH"

  source bash+ :std

  use Test::More

  plan tests 8

  some-command
  ok $? 'some-command is ok'

  # or:
  ok "`some-command`" 'some-command is ok'

  pass 'This will always pass'

  fail 'This will always fail'

  is `echo foo` 'foo' 'foo is foo'

  isnt foo bar "foo isn't bar"

  like food foo 'food is like foo'

  unlike team I "There's no 'I' in 'team'"

  diag "A message for stderr"

  note "A message for stdout"

  output=( $(ls) )
  expected=(README lib bin)
  cmp-array output expected "list files"

Run the test with `prove` like this:

  prove test/test.t

Prove knows it's Bash from the first line (the hashbang), and it just works.

= Description

Test::More is the tried and true testing library for Perl. It uses TAP (the
Test Anything Protocol). This is the same thing for Bash.  For the most part it
should work exactly the same.

= Methods

This is the basic usage:

* `plan tests $count`
* `ok $status_code "$label"`
* `pass "$label"`
* `fail "$label"`
* `is "$got" "$want" "label"`
* `isnt "$got" "$unwanted" "$label"`
* `like "$got" "$regex" "$label"`
* `unlike "$got" "$regex" "$label"`
* `diag "$message"`
* `note "$message"`
* `done_testing $count`
* `plan skip_all "$reason"`
* `BAIL_OUT "$reason"`
* `cmp-array output expected "message"

More detailed info coming soon.

= Author

Ingy döt Net <ingy@ingy.net>

= Copyright & License

Copyright 2013-2020. Ingy döt Net.

The MIT License (MIT)