From cb87271a01ab55671a05db2820c72734a6428753 Mon Sep 17 00:00:00 2001
From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
Date: Mon, 26 Jul 2021 01:24:29 -0700
Subject: genesis: update stand-alone tests to use test stage work directory
 (#24193)

---
 .../repos/builtin/packages/genesis/package.py      | 40 +++++++++++++++-------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/var/spack/repos/builtin/packages/genesis/package.py b/var/spack/repos/builtin/packages/genesis/package.py
index 7e433e5e94..942c334a3b 100644
--- a/var/spack/repos/builtin/packages/genesis/package.py
+++ b/var/spack/repos/builtin/packages/genesis/package.py
@@ -105,21 +105,37 @@ class Genesis(AutotoolsPackage, CudaPackage):
         make("install")
         install_tree("doc", prefix.share.doc)
 
+    @property
+    def cached_tests_work_dir(self):
+        """The working directory for cached test sources."""
+        return join_path(self.test_suite.current_test_cache_dir,
+                         "tests")
+
     @run_after("install")
     def cache_test_sources(self):
+        """Copy test files after the package is installed for test()."""
         if self.spec.satisfies("@master"):
             self.cache_extra_test_sources(["tests"])
 
     def test(self):
-        if self.spec.satisfies("@master"):
-            exe_name = self.spec["python"].command.path
-            test_name = join_path(
-                self.install_test_root, "tests", "regression_test", "test.py"
-            )
-            bin_name = join_path(self.prefix.bin, "spdyn")
-            opts = [
-                test_name,
-                self.spec["mpi"].prefix.bin.mpirun + " -np 8 " + bin_name,
-            ]
-            env["OMP_NUM_THREADS"] = "1"
-            self.run_test(exe_name, options=opts, expected="Passed  53 / 53")
+        """Perform stand-alone/smoke tests using installed package."""
+        if not self.spec.satisfies("@master"):
+            print('Skipping: Tests are only available for the master branch')
+            return
+
+        test_name = join_path(
+            self.cached_tests_work_dir, "regression_test", "test.py"
+        )
+        bin_name = join_path(self.prefix.bin, "spdyn")
+        opts = [
+            test_name,
+            self.spec["mpi"].prefix.bin.mpirun + " -np 8 " + bin_name,
+        ]
+        env["OMP_NUM_THREADS"] = "1"
+        self.run_test(
+            self.spec["python"].command.path,
+            options=opts,
+            expected="Passed  53 / 53",
+            purpose="test: running regression test",
+            work_dir=self.cached_tests_work_dir
+        )
-- 
cgit v1.2.3-70-g09d2