test.sh 1.6 KB

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