diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index a26162e0ad..4fc5a199f1 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -196,6 +196,7 @@ class Context(object): self.heartbeat_interval_ms = 1000 self.original_heartbeat_interval_ms = None self.installed_scripts = [] + self.installed_modules = [] # https://stackoverflow.com/questions/616645/how-do-i-duplicate-sys-stdout-to-a-log-file-in-python @@ -4215,6 +4216,12 @@ class AutoTest(ABC): self.install_test_script(scriptname) self.context_get().installed_scripts.append(scriptname) + def install_test_modules_context(self): + '''installs test modules which will be removed when the context goes + away''' + self.install_test_modules() + self.context_get().installed_modules.append("test") + def install_applet_script_context(self, scriptname): '''installs an applet script which will be removed when the context goes away''' @@ -5654,6 +5661,9 @@ class AutoTest(ABC): self.remove_message_hook(hook) for script in dead.installed_scripts: self.remove_installed_script(script) + for module in dead.installed_modules: + print("Removing module (%s)" % module) + self.remove_installed_modules(module) if dead.sitl_commandline_customised and len(self.contexts): self.contexts[-1].sitl_commandline_customised = True @@ -7629,6 +7639,12 @@ Also, ignores heartbeats not from our target system''' self.progress("Copying (%s) to (%s)" % (source, dest)) shutil.copy(source, dest) + def install_test_modules(self): + source = os.path.join(self.rootdir(), "libraries", "AP_Scripting", "tests", "modules", "test") + dest = os.path.join("scripts", "modules", "test") + self.progress("Copying (%s) to (%s)" % (source, dest)) + shutil.copytree(source, dest) + def install_example_script(self, scriptname): source = self.script_example_source_path(scriptname) self.install_script(source, scriptname) @@ -7650,6 +7666,15 @@ Also, ignores heartbeats not from our target system''' except OSError: pass + def remove_installed_modules(self, modulename): + dest = os.path.join("scripts", "modules", modulename) + try: + shutil.rmtree(dest) + except IOError: + pass + except OSError: + pass + def get_mavlink_connection_going(self): # get a mavlink connection going try: diff --git a/Tools/autotest/rover.py b/Tools/autotest/rover.py index d2e5a40487..c3b3e77d80 100644 --- a/Tools/autotest/rover.py +++ b/Tools/autotest/rover.py @@ -5236,6 +5236,7 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm) "SCR_HEAP_SIZE": 1024000, "SCR_VM_I_COUNT": 1000000, }) + self.install_test_modules_context() for script in test_scripts: self.install_test_script_context(script) self.reboot_sitl()