Address quoting issue impacting dev_paths containing @ symbols (#48555)
* Address quoting issue that casuses dev_paths containing @ symbols to parse as versions
* Fix additional location were dev_path was imporperly constructed
The dev_path must be quoted to avoid parsing issues when
paths contain '@' symbols. Also add tests to catch
regression of this behavior
* Format to fix line length
* fix failing tests
* Fix whitespace error
* Add binary_compatibility fixture to test
* Change string formatting to avoid multiline f string
* Update lib/spack/spack/test/concretization/core.py
* Add tmate debug session
* Revert "Add tmate debug session"
This reverts commit 24e2f77e3c.
* Move test and refactor to use env methods
* Update lib/spack/spack/test/cmd/develop.py
---------
Co-authored-by: psakievich <psakiev@sandia.gov>
			
			
This commit is contained in:
		@@ -114,7 +114,7 @@ def dev_build(self, args):
 | 
			
		||||
    source_path = os.path.abspath(source_path)
 | 
			
		||||
 | 
			
		||||
    # Forces the build to run out of the source directory.
 | 
			
		||||
    spec.constrain("dev_path=%s" % source_path)
 | 
			
		||||
    spec.constrain(f'dev_path="{source_path}"')
 | 
			
		||||
    spec = spack.concretize.concretize_one(spec)
 | 
			
		||||
 | 
			
		||||
    if spec.installed:
 | 
			
		||||
 
 | 
			
		||||
@@ -2711,7 +2711,7 @@ def setup(
 | 
			
		||||
        if env:
 | 
			
		||||
            dev_specs = tuple(
 | 
			
		||||
                spack.spec.Spec(info["spec"]).constrained(
 | 
			
		||||
                    "dev_path=%s"
 | 
			
		||||
                    'dev_path="%s"'
 | 
			
		||||
                    % spack.util.path.canonicalize_path(info["path"], default_wd=env.path)
 | 
			
		||||
                )
 | 
			
		||||
                for name, info in env.dev_specs.items()
 | 
			
		||||
 
 | 
			
		||||
@@ -180,6 +180,18 @@ def test_dev_build_fails_no_version(mock_packages):
 | 
			
		||||
    assert "dev-build spec must have a single, concrete version" in output
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_dev_build_can_parse_path_with_at_symbol(tmpdir, install_mockery):
 | 
			
		||||
    special_char_dir = tmpdir.mkdir("tmp@place")
 | 
			
		||||
    spec = spack.spec.Spec(f'dev-build-test-install@0.0.0 dev_path="{special_char_dir}"')
 | 
			
		||||
    spec.concretize()
 | 
			
		||||
 | 
			
		||||
    with special_char_dir.as_cwd():
 | 
			
		||||
        with open(spec.package.filename, "w", encoding="utf-8") as f:
 | 
			
		||||
            f.write(spec.package.original_string)
 | 
			
		||||
        dev_build("dev-build-test-install@0.0.0")
 | 
			
		||||
    assert spec.package.filename in os.listdir(spec.prefix)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_dev_build_env(tmpdir, install_mockery, mutable_mock_env_path):
 | 
			
		||||
    """Test Spack does dev builds for packages in develop section of env."""
 | 
			
		||||
    # setup dev-build-test-install package for dev build
 | 
			
		||||
 
 | 
			
		||||
@@ -216,3 +216,22 @@ def test_develop_full_git_repo(
 | 
			
		||||
        develop_dir = spec.variants["dev_path"].value
 | 
			
		||||
        commits = _git_commit_list(develop_dir)
 | 
			
		||||
        assert len(commits) > 1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_concretize_dev_path_with_at_symbol_in_env(mutable_mock_env_path, tmpdir, mock_packages):
 | 
			
		||||
    spec_like = "develop-test@develop"
 | 
			
		||||
 | 
			
		||||
    develop_dir = tmpdir.mkdir("build@location")
 | 
			
		||||
    env("create", "test_at_sym")
 | 
			
		||||
 | 
			
		||||
    with ev.read("test_at_sym") as e:
 | 
			
		||||
        add(spec_like)
 | 
			
		||||
        develop(f"--path={develop_dir}", spec_like)
 | 
			
		||||
        e.concretize()
 | 
			
		||||
        result = e.concrete_roots()
 | 
			
		||||
 | 
			
		||||
        assert len(result) == 1
 | 
			
		||||
        cspec = result[0]
 | 
			
		||||
        assert cspec.satisfies(spec_like), cspec
 | 
			
		||||
        assert cspec.is_develop, cspec
 | 
			
		||||
        assert develop_dir in cspec.variants["dev_path"], cspec
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user