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.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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, version 3,
  9. # as published by the Free Software Foundation.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # Usage : ./runtest [OPTIONS] [test_module[.test_class][ test_module2[.test_class2]...]
  20. #########
  21. #
  22. # Options list :
  23. ################
  24. #
  25. # -b, --buffer
  26. #
  27. # 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.
  28. #
  29. # -c, --catch
  30. #
  31. # 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.
  32. #
  33. #
  34. # -f, --failfast
  35. #
  36. # Stop the test run on the first error or failure.
  37. #
  38. # -h, --help
  39. #
  40. # Get some help
  41. #
  42. # -v, --verbose
  43. #
  44. # higher verbosity
  45. #
  46. # Examples :
  47. ############
  48. #
  49. # Running all discoverables tests :
  50. # ./runtest
  51. #
  52. # Running only Em test about component object (only tests about the __init__ and modify_rank methods) with higher verbosity and failfast :
  53. # ./runtest -fv EditorialModel.test.test_component.TestInit EditorialModel.test.test_component.TestModifyRank
  54. #
  55. #
  56. # Running only Em tests
  57. # ./runtest discover EditorialModel
  58. #
  59. # More details :
  60. ################
  61. #
  62. # https://docs.python.org/3.4/library/unittest.html
  63. #
  64. if test ! -f lodel/buildconf.py
  65. then
  66. echo "You have to build the project before running the tests"
  67. echo "See README"
  68. exit 1
  69. fi
  70. PYTHON='env python3'
  71. testdir=$(mktemp -td "lodel2_unittest_instance_XXXXXXXX")
  72. install_model_dir="[@]INSTALLMODEL_DIR[@]"
  73. if [ ! -d "$install_model_dir" ]
  74. then
  75. install_model_dir="$(dirname $0)/progs/slim/install_model/"
  76. fi
  77. libdir="$(dirname $(realpath $0))/lodel"
  78. rmdir $testdir
  79. progs/create_instance test_instance $testdir "$install_model_dir" examples/em_test.pickle "$libdir"
  80. echo progs/create_instance test_instance $testdir "$install_model_dir" examples/em_test.pickle "$libdir"
  81. cp -R examples $testdir
  82. cp -R tests $testdir
  83. cd $testdir
  84. chmod +x lodel_admin.py
  85. rm -R conf.d && mv tests/tests_conf.d conf.d
  86. make
  87. make refresh_plugins
  88. $PYTHON loader.py $@ && ret_status=0 || ret_status=1
  89. rm -Rf $testdir
  90. exit $ret_status