Skip to content

Commit

Permalink
pwcli: fix build script stdout long lines handling
Browse files Browse the repository at this point in the history
If the build script has long lines they were corrupted in the output. Fix that
by limiting print lentgh to the width of the screen and creating the empty_line
based on the width.

Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  • Loading branch information
kvalo committed Feb 20, 2024
1 parent a988fde commit f97fe29
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmdtests/bug-build-with-spaces.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Deferred : 6
Total : 32
master@data > build
build
this is a build script with spaces Build successful
this is a build script with spaces Build successful
master@data > quit
Expand Down
2 changes: 1 addition & 1 deletion cmdtests/cmd-build.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Deferred : 6
Total : 32
master@data > build
build
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c Build successful
12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c Build successful
master@data > quit
Expand Down
2 changes: 1 addition & 1 deletion cmdtests/cmd-commit-build-failure-accept.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ commit 1
commit All/aBort? a
a
Committing patches (1/1)
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c
12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c
Build failed: 1
============================================================
1 patches applied:
Expand Down
2 changes: 1 addition & 1 deletion cmdtests/cmd-commit-build-failure.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ commit 1
commit All/aBort? a
a
Committing patches (1/1)
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c foo.c: warning: is suspicious
12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c foo.c: warning: is suspicious
bar.c: warning: is suspicious
aaa.c: warning: is suspicious
bbb.c: warning: is suspicious
Expand Down
2 changes: 1 addition & 1 deletion cmdtests/cmd-commit-build-warnings-accept.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ commit 1
commit All/aBort? a
a
Committing patches (1/1)
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c foo.c: warning: is suspicious
12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c foo.c: warning: is suspicious
bar.c: warning: is suspicious
aaa.c: warning: is suspicious
bbb.c: warning: is suspicious
Expand Down
2 changes: 1 addition & 1 deletion cmdtests/cmd-review-stg-build-failure-accept.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ review 1
Apply 1 patches to the pending branch? [Apply/Skip/aBort] a
a
Importing patches (1/1)
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c
12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c
Build failed: 1
Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? u
u
Expand Down
2 changes: 1 addition & 1 deletion cmdtests/cmd-review-stg-multiple-abort.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ review 1-5
Apply 5 patches to the pending branch? [Apply/Skip/aBort] a
a
Importing patches (1/5)Importing patches (2/5)Importing patches (3/5)Importing patches (4/5)Importing patches (5/5)
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c Build successful
12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890 CC foo.c CC bar.c CC aaa.c CC bbb.c Build successful
Under review/Changes requested/Rejected/New/Deferred/Superseded/aWaiting upstream/not aPplicable/rFc/aBort? b
b
Aborted.
Expand Down
5 changes: 3 additions & 2 deletions pwcli
Original file line number Diff line number Diff line change
Expand Up @@ -2426,10 +2426,11 @@ class PWCLI():
# build command is not specified, skip the build
return

empty_line = ' '
limit = self.get_terminal_columns()
empty_line = ' ' * limit

def stdout_cb(line):
self.output('\r%s\r%s' % (empty_line, line.replace('\n', '')),
self.output('\r%s\r%s' % (empty_line, line.replace('\n', '')[:limit]),
newline=False)

p = RunProcess(cmd, stdout_cb=stdout_cb)
Expand Down

0 comments on commit f97fe29

Please sign in to comment.