runtests.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. export PYTHONPATH=.
  3. PYTHONVERSION=$(python --version 2>&1)
  4. PYTHONVERSION=${PYTHONVERSION##Python }
  5. function version { echo $@ | gawk -F. '{ printf("%d.%d.%d\n", $1,$2,$3); }'; }
  6. django_test() {
  7. TEST="$1"
  8. OUTPUT=$($TEST 2>&1)
  9. if [ $? -gt 0 ]
  10. then
  11. echo FAIL: $3
  12. $TEST
  13. exit 1;
  14. fi
  15. echo $OUTPUT | grep "Ran $2 test" > /dev/null
  16. if [ $? -gt 0 ]
  17. then
  18. echo FAIL: $3
  19. $TEST
  20. exit 1;
  21. else
  22. echo PASS: $3
  23. fi
  24. # Check that we're hijacking the help correctly.
  25. $TEST --help 2>&1 | grep 'NOSE_DETAILED_ERRORS' > /dev/null
  26. if [ $? -gt 0 ]
  27. then
  28. echo FAIL: $3 '(--help)'
  29. exit 1;
  30. else
  31. echo PASS: $3 '(--help)'
  32. fi
  33. }
  34. django_test 'django-admin.py test --settings=testapp.settings' '2' 'normal settings'
  35. if [ "$DJANGO" = "Django==1.4.1" -o "$DJANGO" = "Django==1.5" -o "$DJANGO" = "Django==1.6" ]
  36. then
  37. django_test 'django-admin.py test --settings=testapp.settings_with_south' '2' 'with south in installed apps'
  38. fi
  39. django_test 'django-admin.py test --settings=testapp.settings_old_style' '2' 'django_nose.run_tests format'
  40. django_test 'testapp/runtests.py testapp.test_only_this' '1' 'via run_tests API'
  41. django_test 'django-admin.py test --settings=testapp.settings_with_plugins testapp/plugin_t' '1' 'with plugins'
  42. django_test 'django-admin.py test --settings=testapp.settings unittests' '4' 'unittests'
  43. if ! [ $(version $PYTHONVERSION) \> $(version 3.0.0) ]
  44. then
  45. # Python 3 doesn't support the hotshot profiler. See nose#842.
  46. django_test 'django-admin.py test --settings=testapp.settings --with-profile' '2' 'with profile plugin'
  47. fi