test_startup.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. run() {
  3. pwd
  4. output=$({ timeout 10 ./$1 $2; } 2>&1)
  5. exitcode=$?
  6. test $exitcode -eq 124 && exitcode=0 # exitcode 124 is comming from "timeout command above"
  7. echo $output | grep -e "NiceGUI ready to go" -e "Uvicorn running on http://127.0.0.1:8000" > /dev/null || exitcode=1
  8. echo $output | grep "Traceback" > /dev/null && exitcode=1
  9. echo $output | grep "Error" > /dev/null && exitcode=1
  10. if test $exitcode -ne 0; then
  11. echo "wrong exit code $exitcode. Output was:"
  12. echo $output
  13. return 1
  14. fi
  15. }
  16. check() {
  17. echo checking $1 ----------
  18. pushd $(dirname "$1") >/dev/null
  19. if run $(basename "$1") $2; then
  20. echo "ok --------"
  21. popd > /dev/null
  22. else
  23. echo "failed -------"
  24. popd > /dev/null
  25. return 1
  26. fi
  27. }
  28. error=0
  29. check main.py || error=1
  30. for path in examples/*
  31. do
  32. if test -f $path/start.sh; then
  33. check $path/start.sh dev || error=1
  34. elif test -f $path/main.py; then
  35. check $path/main.py || error=1
  36. fi
  37. done
  38. test $error -eq 0