From d7242d40824e058eff00bb13fe83debf24dad8be Mon Sep 17 00:00:00 2001 From: Tristan van Berkom Date: Fri, 5 Jun 2020 16:27:21 +0900 Subject: tests/format/junctions.py: Test loading dependencies and targets with full paths --- tests/format/junctions.py | 52 ++++++++++++++++++++++ .../toplevel/element-full-path-notfound.bst | 3 ++ .../junctions/toplevel/element-full-path.bst | 3 ++ .../toplevel/junction-full-path-notfound.bst | 4 ++ .../junctions/toplevel/junction-full-path.bst | 4 ++ 5 files changed, 66 insertions(+) create mode 100644 tests/format/junctions/toplevel/element-full-path-notfound.bst create mode 100644 tests/format/junctions/toplevel/element-full-path.bst create mode 100644 tests/format/junctions/toplevel/junction-full-path-notfound.bst create mode 100644 tests/format/junctions/toplevel/junction-full-path.bst (limited to 'tests/format') 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 -- cgit v1.2.1