tap-bailout.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Basic TAP test protocol support:
  17. # - "Bail out!" magic
  18. . test-init.sh
  19. . tap-setup.sh
  20. : > exp
  21. #------------------------------------------------------------------
  22. # Bailout without explanation.
  23. cat > a.test <<END
  24. 1..4
  25. ok 1
  26. not ok 2
  27. Bail out!
  28. not ok 3
  29. ok 4 # SKIP
  30. END
  31. cat >> exp <<END
  32. PASS: a.test 1
  33. FAIL: a.test 2
  34. ERROR: a.test - Bail out!
  35. END
  36. # pass += 1, fail +=1, error += 1
  37. #------------------------------------------------------------------
  38. # Bailout with explanation.
  39. cat > b.test <<END
  40. 1..7
  41. ok 1 # SKIP
  42. ok 2 # TODO
  43. not ok 3 # TODO
  44. Bail out! We're out of disk space.
  45. ok 4
  46. not ok 5
  47. not ok 6 # TODO
  48. ok 7 # TODO
  49. END
  50. cat >> exp <<END
  51. SKIP: b.test 1 # SKIP
  52. XPASS: b.test 2 # TODO
  53. XFAIL: b.test 3 # TODO
  54. ERROR: b.test - Bail out! We're out of disk space.
  55. END
  56. # skip += 1, xpass += 1, xfail += 1, error += 1
  57. #------------------------------------------------------------------
  58. # Bail out before the test plan.
  59. cat > c.test <<END
  60. ok 1
  61. ok 2
  62. Bail out! BOOOH!
  63. 1..2
  64. END
  65. cat >> exp <<END
  66. PASS: c.test 1
  67. PASS: c.test 2
  68. ERROR: c.test - Bail out! BOOOH!
  69. END
  70. # pass += 2, error += 1
  71. #------------------------------------------------------------------
  72. # Bailout on the first line.
  73. cat > d.test <<END
  74. Bail out! mktemp -d: Permission denied
  75. ok 1
  76. END
  77. echo 'ERROR: d.test - Bail out! mktemp -d: Permission denied' >> exp
  78. # error += 1
  79. #------------------------------------------------------------------
  80. # TAP input comprised only of a bailout directive.
  81. cat > e.test <<END
  82. Bail out!
  83. END
  84. echo "ERROR: e.test - Bail out!" >> exp
  85. # error += 1
  86. #------------------------------------------------------------------
  87. # Doing the sums above, we have:
  88. test_counts='total=12 pass=3 fail=1 xpass=1 xfail=1 skip=1 error=5'
  89. run_make -O -e FAIL TESTS='a.test b.test c.test d.test e.test' check
  90. count_test_results $test_counts
  91. LC_ALL=C sort exp > t
  92. mv -f t exp
  93. # We need the sort below to account for parallel make usage.
  94. grep ': [abcde]\.test' stdout | LC_ALL=C sort > got
  95. cat exp
  96. cat got
  97. diff exp got
  98. :