Fix regressions in unit_tests.sh during pytest mirgation

The pytest migration patch introduced a couple of regression in
tools/unit_tests.sh:

* We no longer cannot run a specific test explicitly
  (per python file, per test class, per specific test).
  Per module like openstack_dashboard, openstack_auth and horizon
  is the only possible way after the pytest migration.
* openstack_dashboard tests outside of openstack_dashboard/test/
  are not looked up when a subset is specified.

This commit restores the orginal behavior.

pytest uses a different way to specify tests.
We cannot use the style of python modules like
"openstack_auth.tests.unit.test_policy.PolicyLoaderTestCase.test_policy_file_load"
and we need to specify tests like file paths [1].

[1] https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests

Closes-Bug: #1875123
Change-Id: Ic4b6c69d8a2ed774cce16521c4c4336f55ff737e
This commit is contained in:
Akihiro Motoki 2020-04-26 14:07:16 +09:00
parent a802f72e71
commit ccaaf8cbb9

View File

@ -23,13 +23,13 @@ single_html="--self-contained-html"
# If we are running a test subset, supply the correct settings file. # If we are running a test subset, supply the correct settings file.
# If not, simply run the entire test suite. # If not, simply run the entire test suite.
if [ -n "$subset" ]; then if [ -n "$subset" ]; then
project="${subset%%.*}" project="${subset%%/*}"
if [ $project == "horizon" ]; then if [ $project == "horizon" ]; then
$testcommand ${1}/horizon/test/ --ds=horizon.test.settings -v -m "$tagarg" $horizon_test_results $single_html $testcommand $posargs --ds=horizon.test.settings -v -m "$tagarg" $horizon_test_results $single_html
elif [ $project == "openstack_dashboard" ]; then elif [ $project == "openstack_dashboard" ]; then
$testcommand ${1}/openstack_dashboard/test/ --ds=openstack_dashboard.test.settings -v -m "$tagarg" $dashboard_test_results $single_html $testcommand $posargs --ds=openstack_dashboard.test.settings -v -m "$tagarg" $dashboard_test_results $single_html
elif [ $project == "openstack_auth" ]; then elif [ $project == "openstack_auth" ]; then
$testcommand ${1}/openstack_auth/tests/ --ds=openstack_auth.tests.settings -v -m "$tagarg" $auth_test_results $single_html $testcommand $posargs --ds=openstack_auth.tests.settings -v -m "$tagarg" $auth_test_results $single_html
elif [ $project == "plugin-test" ]; then elif [ $project == "plugin-test" ]; then
$testcommand ${1}/openstack_dashboard/test/test_plugins --ds=openstack_dashboard.test.settings -v -m plugin_test $plugins_test_results $single_html $testcommand ${1}/openstack_dashboard/test/test_plugins --ds=openstack_dashboard.test.settings -v -m plugin_test $plugins_test_results $single_html
fi fi