2
0

amberVersionTest.sh 922 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # Tests if the `amber version` command returns the expected amber version number, according to the configuration file `package.json`
  3. # Displays 'ok' in green if test succeeds, else 'not ok' in red.
  4. JSON_PACKAGE_PATH='../package.json' # {amber directory}/external/amber-cli/package.json
  5. AMBER_VERSION_COMMAND='../support/amber-cli.js version'
  6. RED="1;31"
  7. GREEN="1;32"
  8. function makeItColorful {
  9. echo -e "\e[$2m$1\e[0m"
  10. }
  11. amberResult=`node $AMBER_VERSION_COMMAND`
  12. expectedAmberVersion=`node --eval "console.log(require('./$JSON_PACKAGE_PATH').version)"`
  13. # tests if expected amber version is in the result of `amber version` command
  14. echo $amberResult | grep $expectedAmberVersion > /dev/null 2>&1
  15. if [ $? -eq 0 ]
  16. then
  17. makeItColorful "ok 1 - amber version" $GREEN
  18. exit 0
  19. else
  20. makeItColorful "$amberResult" $RED
  21. makeItColorful "not ok 1 - amber version\n\texpected : $expectedAmberVersion" $RED
  22. exit 1
  23. fi