test.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. set -x
  3. set -e
  4. # Run anchor test
  5. anchor test --skip-lint
  6. idls_dir=idls
  7. tmp_dir=$(mktemp -d)
  8. cd programs/idl
  9. anchor idl parse --file src/lib.rs -o $tmp_dir/idl_parse_act.json
  10. anchor idl build -o $tmp_dir/idl_build_act.json
  11. cd ../generics
  12. anchor idl build -o $tmp_dir/generics_build_act.json
  13. cd ../relations-derivation
  14. anchor idl build -o $tmp_dir/relations_build_act.json
  15. cd ../..
  16. echo "----------------------------------------------------"
  17. echo "idl parse before > after"
  18. echo "----------------------------------------------------"
  19. echo ""
  20. diff -y --color $idls_dir/idl_parse_exp.json $tmp_dir/idl_parse_act.json
  21. PARSE_RETCODE=$?
  22. echo ""
  23. echo ""
  24. echo "----------------------------------------------------"
  25. echo "idl build before > after"
  26. echo "----------------------------------------------------"
  27. echo ""
  28. diff -y --color $idls_dir/idl_build_exp.json $tmp_dir/idl_build_act.json
  29. GEN_RETCODE=$?
  30. echo ""
  31. echo ""
  32. echo "----------------------------------------------------"
  33. echo "idl generics build before > after"
  34. echo "----------------------------------------------------"
  35. echo ""
  36. diff -y --color $idls_dir/generics_build_exp.json $tmp_dir/generics_build_act.json
  37. GEN_GENERICS_RETCODE=$?
  38. echo ""
  39. echo ""
  40. echo "----------------------------------------------------"
  41. echo "idl relations build before > after"
  42. echo "----------------------------------------------------"
  43. echo ""
  44. diff -y --color $idls_dir/relations_build_exp.json $tmp_dir/relations_build_act.json
  45. GEN_RELATIONS_RETCODE=$?
  46. # returns 0 when ok, or a positive integer when there are differences
  47. exit $((PARSE_RETCODE+GEN_RETCODE+GEN_GENERICS_RETCODE+GEN_RELATIONS_RETCODE))