TF_RUN 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #!/bin/bash
  2. . "$TF_DIR/include/subtest.sh"
  3. . "$TF_DIR/include/tools.sh"
  4. tf_enum_subtests() {
  5. echo uri
  6. echo uris
  7. echo id
  8. echo ids
  9. echo exp
  10. echo exps
  11. echo tag
  12. echo tags
  13. echo kw
  14. echo kws
  15. echo mixed
  16. echo uris_in_lang
  17. }
  18. tf_do_subtest() {
  19. local t_name=$1
  20. local t_in="test/$t_name.stdin"
  21. local o_out="oracle/$t_name.stdout"
  22. {
  23. echo " bz = http://bugzilla.example.com/?query=%s"
  24. echo " g = http://google.example.com/search?q=%s"
  25. echo " storage = ftp://joe:secret@storage%s.files.example.com/"
  26. echo " issue = http://gitlab.example.org/issue?id=%s"
  27. echo " faq = http://faq.example.org/faq/%s"
  28. } > test/example.map
  29. mkdata test > "$t_in"
  30. mkdata oracle > "$o_out"
  31. tf_testflt -i "$t_in" -n "$t_name" -O "$o_out" uripecker test/example.map
  32. }
  33. mkdata() {
  34. local what=$1
  35. case $t_name:$what in
  36. uri:test)
  37. echo "http://distinct.uri1.example.com/"
  38. ;;
  39. uri:oracle)
  40. echo "http://distinct.uri1.example.com"
  41. ;;
  42. uris:test)
  43. echo "http://distinct.uri1.example.com/"
  44. echo "also http://distinct.uri2.example.com/get"
  45. echo "http://distinct.uri3.example.com/?x=1 as well"
  46. echo "then there's http://distinct.uri4.example.com/?x=1&y=2 as well"
  47. echo "and finally:"
  48. echo "http://distinct.uri5.example.com/get?x=1&y=2&foo=bar+%20+baz"
  49. ;;
  50. uris:oracle)
  51. echo "http://distinct.uri1.example.com"
  52. echo "http://distinct.uri2.example.com/get"
  53. echo "http://distinct.uri3.example.com/?x=1"
  54. echo "http://distinct.uri4.example.com/?x=1&y=2"
  55. echo "http://distinct.uri5.example.com/get?x=1&y=2&foo=bar+%20+baz"
  56. ;;
  57. id:test)
  58. echo "bz#123456789"
  59. ;;
  60. id:oracle)
  61. echo "http://bugzilla.example.com/?query=123456789"
  62. ;;
  63. ids:test)
  64. echo "bz#1"
  65. echo "also bz#2"
  66. echo "also bz#345 as well"
  67. echo "then there's bz#42 as well"
  68. echo "and finally:"
  69. echo "bz#6789"
  70. ;;
  71. ids:oracle)
  72. echo "http://bugzilla.example.com/?query=1"
  73. echo "http://bugzilla.example.com/?query=2"
  74. echo "http://bugzilla.example.com/?query=345"
  75. echo "http://bugzilla.example.com/?query=42"
  76. echo "http://bugzilla.example.com/?query=6789"
  77. ;;
  78. exp:test)
  79. echo "bz = 123456789"
  80. ;;
  81. exp:oracle)
  82. echo "http://bugzilla.example.com/?query=123456789"
  83. ;;
  84. exps:test)
  85. echo "bz = 1"
  86. echo "also bz = 2"
  87. echo "also bz = 345 as well"
  88. echo "then there's bz = 42 as well"
  89. echo "and finally:"
  90. echo "bz = 6789"
  91. ;;
  92. exps:oracle)
  93. echo "http://bugzilla.example.com/?query=1"
  94. echo "http://bugzilla.example.com/?query=2"
  95. echo "http://bugzilla.example.com/?query=345"
  96. echo "http://bugzilla.example.com/?query=42"
  97. echo "http://bugzilla.example.com/?query=6789"
  98. ;;
  99. tag:test)
  100. echo "bz123456789"
  101. ;;
  102. tag:oracle)
  103. echo "http://bugzilla.example.com/?query=123456789"
  104. ;;
  105. tags:test)
  106. echo "bz1"
  107. echo "bz345 as well"
  108. echo "and finally:"
  109. echo "bz6789"
  110. ;;
  111. tags:oracle)
  112. echo "http://bugzilla.example.com/?query=1"
  113. echo "http://bugzilla.example.com/?query=345"
  114. echo "http://bugzilla.example.com/?query=6789"
  115. ;;
  116. kw:test)
  117. echo "g foo"
  118. ;;
  119. kw:oracle)
  120. echo "http://google.example.com/search?q=foo"
  121. ;;
  122. kws:test)
  123. echo "g foo"
  124. echo "g bar"
  125. echo "g baz qux quux"
  126. echo "g learn 中文 in no time"
  127. ;;
  128. kws:oracle)
  129. echo "http://google.example.com/search?q=foo"
  130. echo "http://google.example.com/search?q=bar"
  131. echo "http://google.example.com/search?q=baz+qux+quux"
  132. echo "http://google.example.com/search?q=learn+%E4%B8%AD%E6%96%87+in+no+time"
  133. ;;
  134. mixed:test)
  135. echo "issue = 1"
  136. echo "http://other.example.com/"
  137. echo "faq#225"
  138. echo "https://secure.example.com/"
  139. echo "issue42"
  140. echo "https://secure.example.com/foo?id=2&name=bar+baz"
  141. echo "faq 14"
  142. echo "https://urlescape.example.com/foo?name=Jan%20%C5%A0varn%C3%BD%2C%20bytem%20%C5%98e%C4%8Dkovice%2017"
  143. echo "or faq 15"
  144. echo "http://anchor.example.org/foo/bar.html#baz"
  145. echo "ftp://joe:secret@files.example.com/"
  146. echo "storage 42"
  147. ;;
  148. mixed:oracle)
  149. echo "http://other.example.com"
  150. echo "https://secure.example.com"
  151. echo "https://secure.example.com/foo?id=2&name=bar+baz"
  152. echo "https://urlescape.example.com/foo?name=Jan%20%C5%A0varn%C3%BD%2C%20bytem%20%C5%98e%C4%8Dkovice%2017"
  153. echo "http://anchor.example.org/foo/bar.html#baz"
  154. echo "ftp://joe:secret@files.example.com"
  155. echo "http://faq.example.org/faq/225"
  156. echo "http://gitlab.example.org/issue?id=1"
  157. echo "http://gitlab.example.org/issue?id=42"
  158. echo "http://faq.example.org/faq/14"
  159. echo "ftp://joe:secret@storage42.files.example.com/"
  160. ;;
  161. uris_in_lang:test)
  162. echo 'Hello,'
  163. echo ''
  164. echo 'please download the new version here: https://build.example.com/new#build.'
  165. echo 'Full changelog can be found at release notes page(http://release.example.com/cl/v1.2.0) within few minutes.'
  166. echo
  167. echo 'Cheers,'
  168. echo 'Joe'
  169. echo ''
  170. echo '-- '
  171. echo 'Joe the Builder'
  172. echo 'http://joe.example.com/joe#contact'
  173. ;;
  174. uris_in_lang:oracle)
  175. echo 'https://build.example.com/new#build'
  176. echo 'http://release.example.com/cl/v1.2.0'
  177. echo 'http://joe.example.com/joe#contact'
  178. ;;
  179. esac
  180. }
  181. mkdir -p test oracle
  182. tf_do_subtests