From ff0bf71889b041be794e8bd47d5be57f6eb07ad1 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 9 Dec 2020 19:51:43 +0300 Subject: Copy parent scope's test program list in runner's entry() function rather than in scope's constructor --- libbuild2/test/script/runner.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libbuild2/test/script/runner.cxx') diff --git a/libbuild2/test/script/runner.cxx b/libbuild2/test/script/runner.cxx index eb30e02..af5f30a 100644 --- a/libbuild2/test/script/runner.cxx +++ b/libbuild2/test/script/runner.cxx @@ -41,6 +41,18 @@ namespace build2 dr << info << "test id: " << sp.id_path.posix_string (); }); + // Note that we could probably keep the test programs sets fully + // independent across the scopes and check if the program is a test by + // traversing the scopes upwards recursively. Note though, that the + // parent scope's set cannot change during the nested scope execution + // and normally contains just a single entry. Thus, it seems more + // efficient to get rid of the recursion by copying the set from the + // parent now and potentially changing it later on the test variable + // assignment, etc. + // + if (sp.parent != nullptr) + sp.test_programs = sp.parent->test_programs; + // Scope working directory shall be empty (the script working // directory is cleaned up by the test rule prior the script // execution). -- cgit v1.1