From 5628e260f23a37cf16419235819ba05d1248ed51 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 6 Dec 2016 23:07:58 -0500 Subject: [PATCH] Relocate module unit tests. (#18812) * Relocate module unit tests. * Fix classification of unit test changes. --- test/runner/lib/classification.py | 16 ++++++++++++---- test/units/modules/{core => cloud}/__init__.py | 0 .../{core/cloud => cloud/amazon}/__init__.py | 0 .../cloud/amazon/test_ec2_vpc_nat_gateway.py | 0 .../cloud/amazon/test_kinesis_stream.py | 0 .../modules/{core => }/cloud/docker/__init__.py | 0 .../{core => }/cloud/docker/test_docker.py | 0 .../{core => }/cloud/openstack/__init__.py | 0 .../{core => }/cloud/openstack/test_os_server.py | 0 test/units/modules/extras/__init__.py | 0 test/units/modules/extras/cloud/__init__.py | 0 .../modules/extras/cloud/amazon/__init__.py | 0 .../modules/{core => }/packaging/__init__.py | 0 .../modules/{core => }/packaging/os/__init__.py | 0 .../modules/{core => }/packaging/os/test_apt.py | 0 15 files changed, 12 insertions(+), 4 deletions(-) rename test/units/modules/{core => cloud}/__init__.py (100%) rename test/units/modules/{core/cloud => cloud/amazon}/__init__.py (100%) rename test/units/modules/{extras => }/cloud/amazon/test_ec2_vpc_nat_gateway.py (100%) rename test/units/modules/{extras => }/cloud/amazon/test_kinesis_stream.py (100%) rename test/units/modules/{core => }/cloud/docker/__init__.py (100%) rename test/units/modules/{core => }/cloud/docker/test_docker.py (100%) rename test/units/modules/{core => }/cloud/openstack/__init__.py (100%) rename test/units/modules/{core => }/cloud/openstack/test_os_server.py (100%) delete mode 100644 test/units/modules/extras/__init__.py delete mode 100644 test/units/modules/extras/cloud/__init__.py delete mode 100644 test/units/modules/extras/cloud/amazon/__init__.py rename test/units/modules/{core => }/packaging/__init__.py (100%) rename test/units/modules/{core => }/packaging/os/__init__.py (100%) rename test/units/modules/{core => }/packaging/os/test_apt.py (100%) diff --git a/test/runner/lib/classification.py b/test/runner/lib/classification.py index a3cce21292..ee56e7853c 100644 --- a/test/runner/lib/classification.py +++ b/test/runner/lib/classification.py @@ -81,7 +81,7 @@ class PathMapper(object): self.compile_paths = set(t.path for t in self.compile_targets) self.units_modules = set(t.module for t in self.units_targets if t.module) - self.units_paths = set(t.path for t in self.units_targets) + self.units_paths = set(a for t in self.units_targets for a in t.aliases) self.sanity_paths = set(t.path for t in self.sanity_targets) self.module_names_by_path = dict((t.path, t.module) for t in self.module_targets) @@ -280,9 +280,17 @@ class PathMapper(object): 'units': path, } - return { - 'units': '%s/' % os.path.dirname(path), - } + # changes to files which are not unit tests should trigger tests from the nearest parent directory + + test_path = os.path.dirname(path) + + while test_path: + if test_path + '/' in self.units_paths: + return { + 'units': test_path + '/', + } + + test_path = os.path.dirname(test_path) if path.startswith('test/runner/'): return all_tests() # test infrastructure, run all tests diff --git a/test/units/modules/core/__init__.py b/test/units/modules/cloud/__init__.py similarity index 100% rename from test/units/modules/core/__init__.py rename to test/units/modules/cloud/__init__.py diff --git a/test/units/modules/core/cloud/__init__.py b/test/units/modules/cloud/amazon/__init__.py similarity index 100% rename from test/units/modules/core/cloud/__init__.py rename to test/units/modules/cloud/amazon/__init__.py diff --git a/test/units/modules/extras/cloud/amazon/test_ec2_vpc_nat_gateway.py b/test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py similarity index 100% rename from test/units/modules/extras/cloud/amazon/test_ec2_vpc_nat_gateway.py rename to test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py diff --git a/test/units/modules/extras/cloud/amazon/test_kinesis_stream.py b/test/units/modules/cloud/amazon/test_kinesis_stream.py similarity index 100% rename from test/units/modules/extras/cloud/amazon/test_kinesis_stream.py rename to test/units/modules/cloud/amazon/test_kinesis_stream.py diff --git a/test/units/modules/core/cloud/docker/__init__.py b/test/units/modules/cloud/docker/__init__.py similarity index 100% rename from test/units/modules/core/cloud/docker/__init__.py rename to test/units/modules/cloud/docker/__init__.py diff --git a/test/units/modules/core/cloud/docker/test_docker.py b/test/units/modules/cloud/docker/test_docker.py similarity index 100% rename from test/units/modules/core/cloud/docker/test_docker.py rename to test/units/modules/cloud/docker/test_docker.py diff --git a/test/units/modules/core/cloud/openstack/__init__.py b/test/units/modules/cloud/openstack/__init__.py similarity index 100% rename from test/units/modules/core/cloud/openstack/__init__.py rename to test/units/modules/cloud/openstack/__init__.py diff --git a/test/units/modules/core/cloud/openstack/test_os_server.py b/test/units/modules/cloud/openstack/test_os_server.py similarity index 100% rename from test/units/modules/core/cloud/openstack/test_os_server.py rename to test/units/modules/cloud/openstack/test_os_server.py diff --git a/test/units/modules/extras/__init__.py b/test/units/modules/extras/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/units/modules/extras/cloud/__init__.py b/test/units/modules/extras/cloud/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/units/modules/extras/cloud/amazon/__init__.py b/test/units/modules/extras/cloud/amazon/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/units/modules/core/packaging/__init__.py b/test/units/modules/packaging/__init__.py similarity index 100% rename from test/units/modules/core/packaging/__init__.py rename to test/units/modules/packaging/__init__.py diff --git a/test/units/modules/core/packaging/os/__init__.py b/test/units/modules/packaging/os/__init__.py similarity index 100% rename from test/units/modules/core/packaging/os/__init__.py rename to test/units/modules/packaging/os/__init__.py diff --git a/test/units/modules/core/packaging/os/test_apt.py b/test/units/modules/packaging/os/test_apt.py similarity index 100% rename from test/units/modules/core/packaging/os/test_apt.py rename to test/units/modules/packaging/os/test_apt.py