Repository: spack/spack

Issue:
unit tests require network
### Steps to reproduce

```
$ unshare -rn spack unit-test
```

ping @alalazo 


### Error message

FAIL lib/spack/spack/test/bindist.py::test_default_rpaths_create_install_default_layout
FAIL lib/spack/spack/test/bindist.py::test_default_rpaths_install_nondefault_layout
FAIL lib/spack/spack/test/bindist.py::test_relative_rpaths_create_default_layout
FAIL lib/spack/spack/test/bindist.py::test_relative_rpaths_install_default_layout
FAIL lib/spack/spack/test/bindist.py::test_relative_rpaths_install_nondefault
FAIL lib/spack/spack/test/cmd/buildcache.py::test_buildcache_create_fail_on_perm_denied[mock_archive0]
FAIL lib/spack/spack/test/modules/lmod.py::TestLmod::()::test_modules_relative_to_view
ERROR lib/spack/spack/test/bindist.py::test_default_rpaths_create_install_default_layout
ERROR lib/spack/spack/test/modules/lmod.py::TestLmod::()::test_modules_relative_to_view


### Information on your system

* **Spack:** 0.16.2-4011-5823a9b302
* **Python:** 3.8.11
* **Platform:** linux-ubuntu20.04-zen2
* **Concretizer:** clingo


### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have searched the issues of this repo and believe this is not a duplicate
- [X] I have run the failing commands in debug mode and reported the output


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin.mock/packages/corge/package.py b/var/spack/repos/builtin.mock/packages/corge/package.py
--- a/var/spack/repos/builtin.mock/packages/corge/package.py
+++ b/var/spack/repos/builtin.mock/packages/corge/package.py
@@ -14,10 +14,8 @@ class Corge(Package):
     """A toy package to test dependencies"""
 
     homepage = "https://www.example.com"
-    url      = "https://github.com/gartung/corge/archive/v3.0.0.tar.gz"
-
-    version('3.0.0',
-            sha256='5058861c3b887511387c725971984cec665a8307d660158915a04d7786fed6bc')
+    has_code = False
+    version('3.0.0')
 
     depends_on('quux')
 
diff --git a/var/spack/repos/builtin.mock/packages/garply/package.py b/var/spack/repos/builtin.mock/packages/garply/package.py
--- a/var/spack/repos/builtin.mock/packages/garply/package.py
+++ b/var/spack/repos/builtin.mock/packages/garply/package.py
@@ -14,10 +14,8 @@ class Garply(Package):
     """Toy package for testing dependencies"""
 
     homepage = "https://www.example.com"
-    url      = "https://github.com/gartung/garply/archive/v3.0.0.tar.gz"
-
-    version('3.0.0',
-            sha256='534ac8ba7a6fed7e8bbb543bd43ca04999e65337445a531bd296939f5ac2f33d')
+    has_code = False
+    version('3.0.0')
 
     def install(self, spec, prefix):
         garply_h = '''#ifndef GARPLY_H_
diff --git a/var/spack/repos/builtin.mock/packages/quux/package.py b/var/spack/repos/builtin.mock/packages/quux/package.py
--- a/var/spack/repos/builtin.mock/packages/quux/package.py
+++ b/var/spack/repos/builtin.mock/packages/quux/package.py
@@ -14,10 +14,8 @@ class Quux(Package):
     """Toy package for testing dependencies"""
 
     homepage = "https://www.example.com"
-    url      = "https://github.com/gartung/quux/archive/v3.0.0.tar.gz"
-
-    version('3.0.0',
-            sha256='b91bc96fb746495786bddac2c527039177499f2f76d3fa9dcf0b393859e68484')
+    has_code = False
+    version('3.0.0')
 
     depends_on('garply')
 
@@ -90,6 +88,7 @@ class Quux
 const int quux_version_minor = %s;
 '''
         mkdirp('%s/quux' % prefix.include)
+        mkdirp('%s/quux' % self.stage.source_path)
         with open('%s/quux_version.h' % self.stage.source_path, 'w')  as f:
             f.write(quux_version_h % (self.version[0], self.version[1:]))
         with open('%s/quux/quux.cc' % self.stage.source_path, 'w') as f:


Test patch:
diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py
--- a/lib/spack/spack/test/modules/lmod.py
+++ b/lib/spack/spack/test/modules/lmod.py
@@ -339,7 +339,9 @@ def test_config_backwards_compat(self, mutable_config):
         assert old_format == settings['lmod']
 
     def test_modules_relative_to_view(
-            self, tmpdir, modulefile_content, module_configuration, install_mockery):
+        self, tmpdir, modulefile_content, module_configuration, install_mockery,
+        mock_fetch
+    ):
         with ev.Environment(str(tmpdir), with_view=True) as e:
             module_configuration('with_view')
             install('cmake')