summaryrefslogtreecommitdiff
path: root/tests/format
diff options
context:
space:
mode:
Diffstat (limited to 'tests/format')
-rw-r--r--tests/format/include.py21
-rw-r--r--tests/format/include/full_path/elements/element.bst6
-rw-r--r--tests/format/include/full_path/elements/invalid.bst4
-rw-r--r--tests/format/include/full_path/elements/subproject.bst5
-rw-r--r--tests/format/include/full_path/project.conf4
-rw-r--r--tests/format/include/full_path/subproject/elements/subsubproject-junction.bst5
-rw-r--r--tests/format/include/full_path/subproject/files/hello.txt1
-rw-r--r--tests/format/include/full_path/subproject/project.conf4
-rw-r--r--tests/format/include/full_path/subproject/sub.yaml1
-rw-r--r--tests/format/include/full_path/subproject/subsubproject/project.conf2
-rw-r--r--tests/format/include/full_path/subproject/subsubproject/subsub.yaml1
-rw-r--r--tests/format/junctions.py52
-rw-r--r--tests/format/junctions/toplevel/element-full-path-notfound.bst3
-rw-r--r--tests/format/junctions/toplevel/element-full-path.bst3
-rw-r--r--tests/format/junctions/toplevel/junction-full-path-notfound.bst4
-rw-r--r--tests/format/junctions/toplevel/junction-full-path.bst4
-rw-r--r--tests/format/link.py8
-rw-r--r--tests/format/link/notfound/elements/link-full-path.bst4
-rw-r--r--tests/format/link/notfound/elements/target-full-path.bst4
-rw-r--r--tests/format/link/simple-junctions/elements/full-path-link.bst4
-rw-r--r--tests/format/link/simple-junctions/elements/target-full-path.bst4
21 files changed, 143 insertions, 1 deletions
diff --git a/tests/format/include.py b/tests/format/include.py
index 12b043c8e..5c273e1a0 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -310,3 +310,24 @@ def test_option_from_deep_junction(cli, tmpdir, datafiles):
result.assert_success()
loaded = _yaml.load_data(result.output)
assert not loaded.get_bool("is-default")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_include_full_path(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "full_path")
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
+ result.assert_success()
+ loaded = _yaml.load_data(result.output)
+ assert loaded.get_str("bar") == "red"
+ assert loaded.get_str("foo") == "blue"
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_include_invalid_full_path(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "full_path")
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "invalid.bst"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
+ # Make sure the root cause provenance is in the output.
+ assert "invalid.bst [line 4 column 7]" in result.stderr
diff --git a/tests/format/include/full_path/elements/element.bst b/tests/format/include/full_path/elements/element.bst
new file mode 100644
index 000000000..7f6f08b32
--- /dev/null
+++ b/tests/format/include/full_path/elements/element.bst
@@ -0,0 +1,6 @@
+kind: manual
+
+variables:
+ (@):
+ - subproject.bst:sub.yaml
+ - subproject.bst:subsubproject-junction.bst:subsub.yaml
diff --git a/tests/format/include/full_path/elements/invalid.bst b/tests/format/include/full_path/elements/invalid.bst
new file mode 100644
index 000000000..0b5240db0
--- /dev/null
+++ b/tests/format/include/full_path/elements/invalid.bst
@@ -0,0 +1,4 @@
+kind: manual
+
+variables:
+ (@): subproject.bst:subsubproject-junction.bst:pony.yaml
diff --git a/tests/format/include/full_path/elements/subproject.bst b/tests/format/include/full_path/elements/subproject.bst
new file mode 100644
index 000000000..6664eeec6
--- /dev/null
+++ b/tests/format/include/full_path/elements/subproject.bst
@@ -0,0 +1,5 @@
+kind: junction
+
+sources:
+- kind: local
+ path: subproject
diff --git a/tests/format/include/full_path/project.conf b/tests/format/include/full_path/project.conf
new file mode 100644
index 000000000..4e2fb0063
--- /dev/null
+++ b/tests/format/include/full_path/project.conf
@@ -0,0 +1,4 @@
+name: simple
+min-version: 2.0
+
+element-path: elements
diff --git a/tests/format/include/full_path/subproject/elements/subsubproject-junction.bst b/tests/format/include/full_path/subproject/elements/subsubproject-junction.bst
new file mode 100644
index 000000000..018fb8ec4
--- /dev/null
+++ b/tests/format/include/full_path/subproject/elements/subsubproject-junction.bst
@@ -0,0 +1,5 @@
+kind: junction
+
+sources:
+- kind: local
+ path: subsubproject
diff --git a/tests/format/include/full_path/subproject/files/hello.txt b/tests/format/include/full_path/subproject/files/hello.txt
new file mode 100644
index 000000000..ce0136250
--- /dev/null
+++ b/tests/format/include/full_path/subproject/files/hello.txt
@@ -0,0 +1 @@
+hello
diff --git a/tests/format/include/full_path/subproject/project.conf b/tests/format/include/full_path/subproject/project.conf
new file mode 100644
index 000000000..1529ece04
--- /dev/null
+++ b/tests/format/include/full_path/subproject/project.conf
@@ -0,0 +1,4 @@
+name: subproject
+min-version: 2.0
+
+element-path: elements
diff --git a/tests/format/include/full_path/subproject/sub.yaml b/tests/format/include/full_path/subproject/sub.yaml
new file mode 100644
index 000000000..db3359e57
--- /dev/null
+++ b/tests/format/include/full_path/subproject/sub.yaml
@@ -0,0 +1 @@
+bar: "red"
diff --git a/tests/format/include/full_path/subproject/subsubproject/project.conf b/tests/format/include/full_path/subproject/subsubproject/project.conf
new file mode 100644
index 000000000..3b470ccf2
--- /dev/null
+++ b/tests/format/include/full_path/subproject/subsubproject/project.conf
@@ -0,0 +1,2 @@
+name: subsubproject
+min-version: 2.0
diff --git a/tests/format/include/full_path/subproject/subsubproject/subsub.yaml b/tests/format/include/full_path/subproject/subsubproject/subsub.yaml
new file mode 100644
index 000000000..4c78a1a57
--- /dev/null
+++ b/tests/format/include/full_path/subproject/subsubproject/subsub.yaml
@@ -0,0 +1 @@
+foo: "blue"
diff --git a/tests/format/junctions.py b/tests/format/junctions.py
index f097e0b8b..b60d16816 100644
--- a/tests/format/junctions.py
+++ b/tests/format/junctions.py
@@ -417,3 +417,55 @@ def test_junction_show(cli, tmpdir, datafiles):
# Show, assert that it says junction
assert cli.get_element_state(project, "base.bst") == "junction"
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("target", ["junction-full-path.bst", "element-full-path.bst", "foo.bst:base.bst:target.bst"])
+def test_full_path(cli, tmpdir, datafiles, target):
+ project_foo = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project_foo, datafiles, ["base"])
+
+ project = os.path.join(str(datafiles), "toplevel")
+ copy_subprojects(project, datafiles, ["base", "foo", "bar"])
+
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+
+ # FIXME: This file can be removed after removing the junction coalescing feature
+ os.remove(os.path.join(project, "base.bst"))
+
+ # Build, checkout
+ result = cli.run(project=project, args=["build", target])
+ result.assert_success()
+ result = cli.run(project=project, args=["artifact", "checkout", target, "--directory", checkoutdir])
+ result.assert_success()
+
+ # Check that the checkout contains the expected file from base
+ assert os.path.exists(os.path.join(checkoutdir, "base.txt"))
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize(
+ "target,provenance",
+ [
+ ("junction-full-path-notfound.bst", "junction-full-path-notfound.bst [line 3 column 2]"),
+ ("element-full-path-notfound.bst", "element-full-path-notfound.bst [line 3 column 2]"),
+ ("foo.bst:base.bst:pony.bst", None),
+ ],
+)
+def test_full_path_not_found(cli, tmpdir, datafiles, target, provenance):
+ project_foo = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project_foo, datafiles, ["base"])
+
+ project = os.path.join(str(datafiles), "toplevel")
+ copy_subprojects(project, datafiles, ["base", "foo", "bar"])
+
+ # FIXME: This file can be removed after removing the junction coalescing feature
+ os.remove(os.path.join(project, "base.bst"))
+
+ # Build
+ result = cli.run(project=project, args=["build", target])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
+
+ # Check that provenance was provided if expected
+ if provenance:
+ assert provenance in result.stderr
diff --git a/tests/format/junctions/toplevel/element-full-path-notfound.bst b/tests/format/junctions/toplevel/element-full-path-notfound.bst
new file mode 100644
index 000000000..55efaca10
--- /dev/null
+++ b/tests/format/junctions/toplevel/element-full-path-notfound.bst
@@ -0,0 +1,3 @@
+kind: stack
+depends:
+- foo.bst:base.bst:pony.bst
diff --git a/tests/format/junctions/toplevel/element-full-path.bst b/tests/format/junctions/toplevel/element-full-path.bst
new file mode 100644
index 000000000..f58559a76
--- /dev/null
+++ b/tests/format/junctions/toplevel/element-full-path.bst
@@ -0,0 +1,3 @@
+kind: stack
+depends:
+- foo.bst:base.bst:target.bst
diff --git a/tests/format/junctions/toplevel/junction-full-path-notfound.bst b/tests/format/junctions/toplevel/junction-full-path-notfound.bst
new file mode 100644
index 000000000..a57d6ba76
--- /dev/null
+++ b/tests/format/junctions/toplevel/junction-full-path-notfound.bst
@@ -0,0 +1,4 @@
+kind: stack
+depends:
+- junction: foo.bst:base.bst
+ filename: pony.bst
diff --git a/tests/format/junctions/toplevel/junction-full-path.bst b/tests/format/junctions/toplevel/junction-full-path.bst
new file mode 100644
index 000000000..4a4f67d19
--- /dev/null
+++ b/tests/format/junctions/toplevel/junction-full-path.bst
@@ -0,0 +1,4 @@
+kind: stack
+depends:
+- junction: foo.bst:base.bst
+ filename: target.bst
diff --git a/tests/format/link.py b/tests/format/link.py
index 47e19b90c..e2c9e0b84 100644
--- a/tests/format/link.py
+++ b/tests/format/link.py
@@ -59,7 +59,9 @@ def test_conditional_link(cli, tmpdir, datafiles, target, greeting, expected_fil
# Test links to junctions from local projects and subprojects
#
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target", ["target-local.bst", "target-nested.bst"])
+@pytest.mark.parametrize(
+ "target", ["target-local.bst", "target-nested.bst", "full-path-link.bst", "target-full-path.bst"]
+)
def test_simple_junctions(cli, tmpdir, datafiles, target):
project = os.path.join(str(datafiles), "simple-junctions")
checkoutdir = os.path.join(str(tmpdir), "checkout")
@@ -115,6 +117,10 @@ def test_conditional_junctions(cli, tmpdir, datafiles, greeting, expected_file):
("linked-local-junction.bst", "subproject-link-notfound.bst [line 4 column 10]",),
# Depends on an element via a link to a non-existing subproject junction
("linked-nested-junction.bst", "subsubproject-link-notfound.bst [line 4 column 10]",),
+ # Target is a link to a non-existing nested element referred to with a full path
+ ("link-full-path.bst", "link-full-path.bst [line 4 column 10]"),
+ # Target depends on a link to a non-existing nested element referred to with a full path
+ ("target-full-path.bst", "link-full-path.bst [line 4 column 10]"),
],
)
def test_link_not_found(cli, tmpdir, datafiles, target, provenance):
diff --git a/tests/format/link/notfound/elements/link-full-path.bst b/tests/format/link/notfound/elements/link-full-path.bst
new file mode 100644
index 000000000..a619c549a
--- /dev/null
+++ b/tests/format/link/notfound/elements/link-full-path.bst
@@ -0,0 +1,4 @@
+kind: link
+
+config:
+ target: subproject.bst:subsubproject-junction.bst:pony.bst
diff --git a/tests/format/link/notfound/elements/target-full-path.bst b/tests/format/link/notfound/elements/target-full-path.bst
new file mode 100644
index 000000000..ad67c343e
--- /dev/null
+++ b/tests/format/link/notfound/elements/target-full-path.bst
@@ -0,0 +1,4 @@
+kind: stack
+
+depends:
+- link-full-path.bst
diff --git a/tests/format/link/simple-junctions/elements/full-path-link.bst b/tests/format/link/simple-junctions/elements/full-path-link.bst
new file mode 100644
index 000000000..306e18cb2
--- /dev/null
+++ b/tests/format/link/simple-junctions/elements/full-path-link.bst
@@ -0,0 +1,4 @@
+kind: link
+
+config:
+ target: subproject.bst:subsubproject-junction.bst:hello.bst
diff --git a/tests/format/link/simple-junctions/elements/target-full-path.bst b/tests/format/link/simple-junctions/elements/target-full-path.bst
new file mode 100644
index 000000000..3fdc9519a
--- /dev/null
+++ b/tests/format/link/simple-junctions/elements/target-full-path.bst
@@ -0,0 +1,4 @@
+kind: stack
+
+depends:
+- full-path-link.bst