Merge lp:~sylvain-pineau/checkbox/mute_job_ouput_flag into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 4510
Merged at revision: 4508
Proposed branch: lp:~sylvain-pineau/checkbox/mute_job_ouput_flag
Merge into: lp:checkbox
Diff against target: 51 lines (+15/-4)
3 files modified
checkbox-ng/launchers/checkbox-cli (+3/-2)
plainbox/plainbox/impl/commands/inv_run.py (+3/-2)
plainbox/plainbox/impl/unit/job.py (+9/-0)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/mute_job_ouput_flag
Reviewer Review Type Date Requested Status
Pierre Equoy Approve
Review via email: mp+306523@code.launchpad.net

Description of the change

A new job flag to mute commands a bit too verbose or potentially containing false alarms.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

When landed, I'll propose to add it to all ipdt tests ;)

Revision history for this message
Pierre Equoy (pieq) wrote :

+1

I tested it by creating this job:

    plugin: shell
    id: smoke/list-dir
    command: ls /
    _description: List root directory

I ran it using both plainbox (plainbox run -i .*list-dir) and checkbox-cli and it produced the following output:

-------------------------------[ smoke/list-dir ]-------------------------------
ID: 2013.com.canonical.certification::smoke/list-dir
Category: 2013.com.canonical.plainbox::uncategorised
... 8< -------------------------------------------------------------------------
bin
boot
cdrom
dev
etc
home
initrd.img
initrd.img.old
lib
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
snap
srv
sys
tmp
usr
var
vmlinuz
vmlinuz.old
------------------------------------------------------------------------- >8 ---
Outcome: job passed
 ☑ : smoke/list-dir

I then added the `suppress-output` flag in the job definition:

    plugin: shell
    id: smoke/list-dir
    flags: suppress-output
    command: ls /
    _description: List root directory

and rerun the test and got the following output:

-------------------------------[ smoke/list-dir ]-------------------------------
ID: 2013.com.canonical.certification::smoke/list-dir
Category: 2013.com.canonical.plainbox::uncategorised
(Command output hidden)
Outcome: job passed
 ☑ : smoke/list-dir

Looks good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-ng/launchers/checkbox-cli'
2--- checkbox-ng/launchers/checkbox-cli 2016-09-21 03:35:24 +0000
3+++ checkbox-ng/launchers/checkbox-cli 2016-09-22 18:56:29 +0000
4@@ -437,8 +437,9 @@
5 estimated_time -= job.estimated_duration
6
7 def _get_ui_for_job(self, job):
8- if not self.launcher.dont_suppress_output and job.plugin in (
9- 'local', 'resource', 'attachment'):
10+ if not self.launcher.dont_suppress_output and (job.plugin in (
11+ 'local', 'resource', 'attachment') or
12+ 'suppress-output' in job.get_flag_set()):
13 return CheckboxUI(self.C.c, show_cmd_output=False)
14 else:
15 return CheckboxUI(self.C.c, show_cmd_output=True)
16
17=== modified file 'plainbox/plainbox/impl/commands/inv_run.py'
18--- plainbox/plainbox/impl/commands/inv_run.py 2016-02-05 10:48:12 +0000
19+++ plainbox/plainbox/impl/commands/inv_run.py 2016-09-22 18:56:29 +0000
20@@ -756,8 +756,9 @@
21 self.run_single_job_with_ui(job, self.get_ui_for_job(job))
22
23 def get_ui_for_job(self, job):
24- if self.ns.dont_suppress_output is False and job.plugin in (
25- 'local', 'resource', 'attachment'):
26+ if self.ns.dont_suppress_output is False and (job.plugin in (
27+ 'local', 'resource', 'attachment') or
28+ 'suppress-output' in job.get_flag_set()):
29 return NormalUI(self.C.c, show_cmd_output=False)
30 else:
31 return NormalUI(self.C.c, show_cmd_output=True)
32
33=== modified file 'plainbox/plainbox/impl/unit/job.py'
34--- plainbox/plainbox/impl/unit/job.py 2016-08-30 08:09:18 +0000
35+++ plainbox/plainbox/impl/unit/job.py 2016-09-22 18:56:29 +0000
36@@ -988,6 +988,15 @@
37 'preserve-cwd makes no sense without a command'
38 ),
39 onlyif=lambda unit: unit.command is None),
40+ # The suppress-output flag is useless without a command
41+ CorrectFieldValueValidator(
42+ lambda value, unit: (
43+ 'suppress-output' not in unit.get_flag_set()),
44+ Problem.useless, Severity.advice,
45+ message=_(
46+ 'suppress-output makes no sense without a command'
47+ ),
48+ onlyif=lambda unit: unit.command is None),
49 ],
50 fields.qml_file: [
51 UntranslatableFieldValidator,

Subscribers

People subscribed via source and target branches