Merge ~jugmac00/lpci:improve-exception-message-for-handling-mutliple-jobs into lpci:main

Proposed by Jürgen Gmach
Status: Merged
Approved by: Jürgen Gmach
Approved revision: 6b6b9b15510cbbb7391c269923fdc1f6a945ffdd
Merged at revision: 6b6b9b15510cbbb7391c269923fdc1f6a945ffdd
Proposed branch: ~jugmac00/lpci:improve-exception-message-for-handling-mutliple-jobs
Merge into: lpci:main
Diff against target: 56 lines (+8/-15)
3 files modified
NEWS.rst (+1/-1)
lpcraft/commands/run.py (+1/-1)
lpcraft/commands/tests/test_run.py (+6/-13)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+428556@code.launchpad.net

Commit message

Improve exception message for handling input

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

A reported bug ( https://bugs.launchpad.net/lpcraft/+bug/1986244 ) was not really easily debugged as the exception message lacked some information.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Jürgen Gmach (jugmac00) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/NEWS.rst b/NEWS.rst
2index 7c1d301..ca8b502 100644
3--- a/NEWS.rst
4+++ b/NEWS.rst
5@@ -5,7 +5,7 @@ Version history
6 0.0.27 (unreleased)
7 ===================
8
9-- Nothing yet.
10+- Improve exception message for handling input when there are multiple jobs.
11
12 0.0.26 (2022-08-12)
13 ===================
14diff --git a/lpcraft/commands/run.py b/lpcraft/commands/run.py
15index 20d59a7..803889a 100644
16--- a/lpcraft/commands/run.py
17+++ b/lpcraft/commands/run.py
18@@ -135,7 +135,7 @@ def _copy_input_paths(
19 raise CommandError(
20 f"Requested input from {input.job_name!r}, but more than one job "
21 f"with that name was previously executed and produced output "
22- f"artifacts."
23+ f"artifacts in the following paths: {source_jobs!r}."
24 )
25 source_path = source_jobs[0]
26
27diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
28index 183eeab..604b13e 100644
29--- a/lpcraft/commands/tests/test_run.py
30+++ b/lpcraft/commands/tests/test_run.py
31@@ -1621,19 +1621,12 @@ class TestRun(RunBaseTestCase):
32 "run", "--output-directory", str(target_path)
33 )
34
35- self.assertThat(
36- result,
37- MatchesStructure.byEquality(
38- exit_code=1,
39- errors=[
40- CommandError(
41- "Requested input from 'build', but more than one job "
42- "with that name was previously executed and produced "
43- "output artifacts.",
44- retcode=1,
45- )
46- ],
47- ),
48+ self.assertEqual(1, result.exit_code)
49+ self.assertRegex(
50+ str(result.errors[0]),
51+ r"Requested input from 'build', but more than one job with that "
52+ r"name was previously executed and produced output artifacts in "
53+ r"the following paths: \[PosixPath\('.*'\), PosixPath\('.*'\)\]\.",
54 )
55
56 @patch("lpcraft.env.get_managed_environment_project_path")

Subscribers

People subscribed via source and target branches