No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtest_context.sh 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. #
  3. # This file is part of Lodel 2 (https://github.com/OpenEdition)
  4. #
  5. # Copyright (C) 2015-2017 Cléo UMS-3287
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as published
  9. # by the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. # Usage : ./runtest [OPTIONS] [test_module[.test_class][ test_module2[.test_class2]...]
  21. #########
  22. #
  23. # Options list :
  24. ################
  25. #
  26. # -b, --buffer
  27. #
  28. # The standard output and standard error streams are buffered during the test run. Output during a passing test is discarded. Output is echoed normally on test fail or error and is added to the failure messages.
  29. #
  30. # -c, --catch
  31. #
  32. # Control-C during the test run waits for the current test to end and then reports all the results so far. A second control-C raises the normal KeyboardInterrupt exception.
  33. #
  34. #
  35. # -f, --failfast
  36. #
  37. # Stop the test run on the first error or failure.
  38. #
  39. # -h, --help
  40. #
  41. # Get some help
  42. #
  43. # -v, --verbose
  44. #
  45. # higher verbosity
  46. #
  47. # Examples :
  48. ############
  49. #
  50. # Running all discoverables tests :
  51. # ./runtest
  52. #
  53. # Running only Em test about component object (only tests about the __init__ and modify_rank methods) with higher verbosity and failfast :
  54. # ./runtest -fv EditorialModel.test.test_component.TestInit EditorialModel.test.test_component.TestModifyRank
  55. #
  56. #
  57. # Running only Em tests
  58. # ./runtest discover EditorialModel
  59. #
  60. # More details :
  61. ################
  62. #
  63. # https://docs.python.org/3.4/library/unittest.html
  64. #
  65. if test ! -f lodel/buildconf.py
  66. then
  67. echo "You have to build the project before running the tests"
  68. echo "See README"
  69. exit 1
  70. fi
  71. PYTHON='env python3'
  72. testdir=$(mktemp -td "lodel2_unittest_instance_XXXXXXXX")
  73. install_model_dir="[@]INSTALLMODEL_DIR[@]"
  74. if [ ! -d "$install_model_dir" ]
  75. then
  76. install_model_dir="$(dirname $0)/progs/slim/install_model/"
  77. fi
  78. libdir="$(dirname $(realpath $0))/lodel"
  79. rmdir $testdir
  80. progs/create_instance test_instance $testdir "$install_model_dir" examples/em_test.pickle "$libdir"
  81. echo progs/create_instance test_instance $testdir "$install_model_dir" examples/em_test.pickle "$libdir"
  82. cp -R examples $testdir
  83. cp -R tests $testdir
  84. cd $testdir
  85. chmod +x lodel_admin.py
  86. rm -R conf.d && mv tests/tests_conf.d conf.d
  87. make
  88. make refresh_plugins
  89. $PYTHON loader.py $@ && ret_status=0 || ret_status=1
  90. rm -Rf $testdir
  91. exit $ret_status