tests.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash
  2. # Run all the different permutations of all the tests.
  3. # This helps ensure that nothing gets broken.
  4. _run() {
  5. # 1. VARIATIONS: regular (t), canonical (c), IO R/W (i),
  6. # binc-nosymbols (n), struct2array (s), intern string (e),
  7. # json-indent (d), circular (l)
  8. # 2. MODE: reflection (r), external (x), codecgen (g), unsafe (u), notfastpath (f)
  9. # 3. OPTIONS: verbose (v), reset (z), must (m),
  10. #
  11. # Use combinations of mode to get exactly what you want,
  12. # and then pass the variations you need.
  13. ztags=""
  14. zargs=""
  15. local OPTIND
  16. OPTIND=1
  17. while getopts "_xurtcinsvgzmefdl" flag
  18. do
  19. case "x$flag" in
  20. 'xr') ;;
  21. 'xf') ztags="$ztags notfastpath" ;;
  22. 'xg') ztags="$ztags codecgen" ;;
  23. 'xx') ztags="$ztags x" ;;
  24. 'xu') ztags="$ztags unsafe" ;;
  25. 'xv') zargs="$zargs -tv" ;;
  26. 'xz') zargs="$zargs -tr" ;;
  27. 'xm') zargs="$zargs -tm" ;;
  28. 'xl') zargs="$zargs -tl" ;;
  29. *) ;;
  30. esac
  31. done
  32. # shift $((OPTIND-1))
  33. printf '............. TAGS: %s .............\n' "$ztags"
  34. # echo ">>>>>>> TAGS: $ztags"
  35. OPTIND=1
  36. while getopts "_xurtcinsvgzmefdl" flag
  37. do
  38. case "x$flag" in
  39. 'xt') printf ">>>>>>> REGULAR : "; go test "-tags=$ztags" $zargs ; sleep 2 ;;
  40. 'xc') printf ">>>>>>> CANONICAL : "; go test "-tags=$ztags" $zargs -tc; sleep 2 ;;
  41. 'xi') printf ">>>>>>> I/O : "; go test "-tags=$ztags" $zargs -ti; sleep 2 ;;
  42. 'xn') printf ">>>>>>> NO_SYMBOLS : "; go test "-tags=$ztags" -run=Binc $zargs -tn; sleep 2 ;;
  43. 'xs') printf ">>>>>>> TO_ARRAY : "; go test "-tags=$ztags" $zargs -ts; sleep 2 ;;
  44. 'xe') printf ">>>>>>> INTERN : "; go test "-tags=$ztags" $zargs -te; sleep 2 ;;
  45. 'xd') printf ">>>>>>> INDENT : ";
  46. go test "-tags=$ztags" -run=JsonCodecsTable -td=-1 $zargs;
  47. go test "-tags=$ztags" -run=JsonCodecsTable -td=8 $zargs;
  48. sleep 2 ;;
  49. *) ;;
  50. esac
  51. done
  52. shift $((OPTIND-1))
  53. OPTIND=1
  54. }
  55. # echo ">>>>>>> RUNNING VARIATIONS OF TESTS"
  56. if [[ "x$@" = "x" || "x$@" = "x-A" ]]; then
  57. # All: r, x, g, gu
  58. _run "-_tcinsed_ml" # regular
  59. _run "-_tcinsed_ml_z" # regular with reset
  60. _run "-_tcinsed_ml_f" # regular with no fastpath (notfastpath)
  61. _run "-x_tcinsed_ml" # external
  62. _run "-gx_tcinsed_ml" # codecgen: requires external
  63. _run "-gxu_tcinsed_ml" # codecgen + unsafe
  64. elif [[ "x$@" = "x-Z" ]]; then
  65. # Regular
  66. _run "-_tcinsed_ml" # regular
  67. _run "-_tcinsed_ml_z" # regular with reset
  68. elif [[ "x$@" = "x-F" ]]; then
  69. # regular with notfastpath
  70. _run "-_tcinsed_ml_f" # regular
  71. _run "-_tcinsed_ml_zf" # regular with reset
  72. elif [[ "x$@" = "x-C" ]]; then
  73. # codecgen
  74. _run "-gx_tcinsed_ml" # codecgen: requires external
  75. _run "-gxu_tcinsed_ml" # codecgen + unsafe
  76. elif [[ "x$@" = "x-X" ]]; then
  77. # external
  78. _run "-x_tcinsed_ml" # external
  79. elif [[ "x$@" = "x-h" || "x$@" = "x-?" ]]; then
  80. cat <<EOF
  81. Usage: tests.sh [options...]
  82. -A run through all tests (regular, external, codecgen)
  83. -Z regular tests only
  84. -F regular tests only (without fastpath, so they run quickly)
  85. -C codecgen only
  86. -X external only
  87. -h show help (usage)
  88. -? same as -h
  89. (no options)
  90. same as -A
  91. (unrecognized options)
  92. just pass on the options from the command line
  93. EOF
  94. else
  95. _run "$@"
  96. fi