Working Saturnin-based meta-command

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. #shellcheck disable=SC1090
  3. . "$TF_DIR/include/subtest.sh"
  4. . "$TF_DIR/include/tools.sh"
  5. tf_enum_subtests() {
  6. echo name
  7. echo name_ex
  8. echo world
  9. }
  10. mkini() {
  11. mkdir -p "test/ini"
  12. {
  13. echo '[echo]'
  14. echo ' prefix = Hello'
  15. } > "test/ini/echo.ini"
  16. }
  17. mkoracle_out() {
  18. mkdir -p oracle
  19. case $TF_SUBTEST in
  20. name) echo 'HelloJoe' ;;
  21. name_ex) echo 'HelloMaggie!' ;;
  22. world) echo 'HelloWorld' ;;
  23. esac > "oracle/$TF_SUBTEST.stdout"
  24. }
  25. mkoracle_err() {
  26. mkdir -p oracle
  27. true > "oracle/$TF_SUBTEST.stderr"
  28. }
  29. mkoracle_es() {
  30. return 0
  31. }
  32. mkresult() {
  33. local what
  34. case $TF_SUBTEST in
  35. name) what="Joe" ;;
  36. name_ex) what="Maggie!" ;;
  37. world) what="World" ;;
  38. esac
  39. (
  40. export PRETTY=plain
  41. export SATURNIN_CONF_PATH="test/ini"
  42. saturnin-demo echo "$what"
  43. )
  44. }
  45. tf_do_subtest() {
  46. local o_es
  47. mkini
  48. mkoracle_out
  49. mkoracle_err
  50. mkoracle_es; o_es=$?
  51. tf_testflt \
  52. -n "$TF_SUBTEST" \
  53. -O "oracle/$TF_SUBTEST.stdout" \
  54. -E "oracle/$TF_SUBTEST.stderr" \
  55. -S "$o_es" \
  56. "mkresult"
  57. }
  58. tf_do_subtests