tests.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. # "_xurtcinsvgzmefdl" === "_cdefgilmnrtsuvxz"
  18. while getopts "_cdefgilmnrtsuvwxz" flag
  19. do
  20. case "x$flag" in
  21. 'xr') ;;
  22. 'xf') ztags="$ztags notfastpath" ;;
  23. 'xg') ztags="$ztags codecgen" ;;
  24. 'xx') ztags="$ztags x" ;;
  25. 'xu') ztags="$ztags unsafe" ;;
  26. 'xv') zargs="$zargs -tv" ;;
  27. 'xz') zargs="$zargs -tr" ;;
  28. 'xm') zargs="$zargs -tm" ;;
  29. 'xl') zargs="$zargs -tl" ;;
  30. 'xw') zargs="$zargs -tx=10" ;;
  31. *) ;;
  32. esac
  33. done
  34. # shift $((OPTIND-1))
  35. printf '............. TAGS: %s .............\n' "$ztags"
  36. # echo ">>>>>>> TAGS: $ztags"
  37. OPTIND=1
  38. while getopts "_cdefgilmnrtsuvwxz" flag
  39. do
  40. case "x$flag" in
  41. 'xt') printf ">>>>>>> REGULAR : "; go test "-tags=$ztags" $zargs ; sleep 2 ;;
  42. 'xc') printf ">>>>>>> CANONICAL : "; go test "-tags=$ztags" $zargs -tc; sleep 2 ;;
  43. 'xi') printf ">>>>>>> I/O : "; go test "-tags=$ztags" $zargs -ti; sleep 2 ;;
  44. 'xn') printf ">>>>>>> NO_SYMBOLS : "; go test "-tags=$ztags" -run=Binc $zargs -tn; sleep 2 ;;
  45. 'xs') printf ">>>>>>> TO_ARRAY : "; go test "-tags=$ztags" $zargs -ts; sleep 2 ;;
  46. 'xe') printf ">>>>>>> INTERN : "; go test "-tags=$ztags" $zargs -te; sleep 2 ;;
  47. 'xd') printf ">>>>>>> INDENT : ";
  48. go test "-tags=$ztags" -run=JsonCodecsTable -td=-1 $zargs;
  49. go test "-tags=$ztags" -run=JsonCodecsTable -td=8 $zargs;
  50. sleep 2 ;;
  51. *) ;;
  52. esac
  53. done
  54. shift $((OPTIND-1))
  55. OPTIND=1
  56. }
  57. # echo ">>>>>>> RUNNING VARIATIONS OF TESTS"
  58. if [[ "x$@" = "x" || "x$@" = "x-A" ]]; then
  59. # All: r, x, g, gu
  60. _run "-_tcinsed_ml" # regular
  61. _run "-_tcinsed_ml_z" # regular with reset
  62. _run "-w_tcinsed_ml" # regular with max init len
  63. _run "-_tcinsed_ml_f" # regular with no fastpath (notfastpath)
  64. _run "-x_tcinsed_ml" # external
  65. _run "-gx_tcinsed_ml" # codecgen: requires external
  66. _run "-gxu_tcinsed_ml" # codecgen + unsafe
  67. elif [[ "x$@" = "x-Z" ]]; then
  68. # Regular
  69. _run "-_tcinsed_ml" # regular
  70. _run "-_tcinsed_ml_z" # regular with reset
  71. elif [[ "x$@" = "x-F" ]]; then
  72. # regular with notfastpath
  73. _run "-_tcinsed_ml_f" # regular
  74. _run "-_tcinsed_ml_zf" # regular with reset
  75. elif [[ "x$@" = "x-C" ]]; then
  76. # codecgen
  77. _run "-gx_tcinsed_ml" # codecgen: requires external
  78. _run "-gxu_tcinsed_ml" # codecgen + unsafe
  79. _run "-gxuw_tcinsed_ml" # codecgen + unsafe + maxinitlen
  80. elif [[ "x$@" = "x-X" ]]; then
  81. # external
  82. _run "-x_tcinsed_ml" # external
  83. elif [[ "x$@" = "x-h" || "x$@" = "x-?" ]]; then
  84. cat <<EOF
  85. Usage: tests.sh [options...]
  86. -A run through all tests (regular, external, codecgen)
  87. -Z regular tests only
  88. -F regular tests only (without fastpath, so they run quickly)
  89. -C codecgen only
  90. -X external only
  91. -h show help (usage)
  92. -? same as -h
  93. (no options)
  94. same as -A
  95. (unrecognized options)
  96. just pass on the options from the command line
  97. EOF
  98. else
  99. # e.g. ./tests.sh "-w_tcinsed_ml"
  100. _run "$@"
  101. fi