← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/lpcraft:improve-exception-message-for-handling-mutliple-jobs into lpcraft:main

 

Jürgen Gmach has proposed merging ~jugmac00/lpcraft:improve-exception-message-for-handling-mutliple-jobs into lpcraft:main.

Commit message:
Improve exception message for handling input

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/lpcraft/+git/lpcraft/+merge/428556
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/lpcraft:improve-exception-message-for-handling-mutliple-jobs into lpcraft:main.
diff --git a/NEWS.rst b/NEWS.rst
index 7c1d301..ca8b502 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -5,7 +5,7 @@ Version history
 0.0.27 (unreleased)
 ===================
 
-- Nothing yet.
+- Improve exception message for handling input when there are multiple jobs.
 
 0.0.26 (2022-08-12)
 ===================
diff --git a/lpcraft/commands/run.py b/lpcraft/commands/run.py
index 20d59a7..803889a 100644
--- a/lpcraft/commands/run.py
+++ b/lpcraft/commands/run.py
@@ -135,7 +135,7 @@ def _copy_input_paths(
         raise CommandError(
             f"Requested input from {input.job_name!r}, but more than one job "
             f"with that name was previously executed and produced output "
-            f"artifacts."
+            f"artifacts in the following paths: {source_jobs!r}."
         )
     source_path = source_jobs[0]
 
diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
index 183eeab..f67d8cf 100644
--- a/lpcraft/commands/tests/test_run.py
+++ b/lpcraft/commands/tests/test_run.py
@@ -1621,19 +1621,13 @@ class TestRun(RunBaseTestCase):
             "run", "--output-directory", str(target_path)
         )
 
-        self.assertThat(
-            result,
-            MatchesStructure.byEquality(
-                exit_code=1,
-                errors=[
-                    CommandError(
-                        "Requested input from 'build', but more than one job "
-                        "with that name was previously executed and produced "
-                        "output artifacts.",
-                        retcode=1,
-                    )
-                ],
-            ),
+        self.assertEqual(1, result.exit_code)
+        self.assertRegex(
+            str(result.errors[0]),
+            r"Requested input from 'build', but more than one job with that"
+            r" name was previously executed and produced output artifacts in "
+            r"the following paths: \[PosixPath\('.*/build/1'\), "
+            r"PosixPath\('.*/build/0'\)\]\.",
         )
 
     @patch("lpcraft.env.get_managed_environment_project_path")

Follow ups