SHARE
TWEET

Untitled

a guest Sep 17th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. tap_inited=false
  4. tap_i=0
  5. tap_exitstatus=0
  6.  
  7. tap_printline()
  8. {
  9.     [ "$1" -eq 0 ] && printf "ok %d - %s\n" $tap_i "$current" && return;
  10.  
  11.     printf "not ok %d - %s\n" $tap_i "$current"
  12.     tap_exitstatus=1
  13. }
  14.  
  15. tap_test() {
  16.     lastexitstatus=$?
  17.  
  18.     ! $tap_inited && current="$1" && tap_inited=true && tap_pretest && return;
  19.  
  20.     tap_i=$((tap_i+1))
  21.  
  22.     tap_printline $lastexitstatus
  23.     tap_posttest
  24.     current=$1
  25.     tap_pretest
  26. }
  27.  
  28. tap_printplan() {
  29.     printf "1..%s\n" "$tap_i"
  30. }
  31.  
  32. tap_finish() {
  33.     lastexitstatus=$?
  34.     [ -z "$current" ] && exit
  35.     tap_printline $lastexitstatus
  36.     tap_printplan
  37.     exit $tap_exitstatus
  38. }
  39.  
  40. trap tap_finish EXIT
  41.  
  42. tap_pretest() {
  43.     true
  44. }
  45.  
  46. tap_posttest() {
  47.     true
  48. }
  49.  
  50. tap_test "one plus zero is zero"
  51. sum=$((1+0))
  52. [ $sum -eq 0 ]
  53.  
  54. tap_test "one plus one is two"
  55. sum=$((1+1))
  56. [ $sum -eq 2 ]
  57.  
  58. tap_test "one plus one is three"
  59. sum=$((1+1))
  60. [ $sum -eq 3 ]
  61.  
  62. tap_test "two plus two is four"
  63. sum=$((2+2))
  64. [ $sum -eq 4 ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top