Skip to content

Commit 24fac27

Browse files
authored
truncate the output of wait (#173)
without this, there is greater risk of going up the wrong number of lines to overwrite each entry with yacspin
1 parent 06d16ff commit 24fac27

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

internal/command/smarttest/printers.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func printTestExecutionsTable(w io.Writer, txs []*models.TestexecutionsQueryResu
149149
tab.AddRow(testExecRow{
150150
ID: tx.ID,
151151
Source: source,
152-
TestName: truncateTestName(testName),
152+
TestName: truncateTestName(testName, 48),
153153
Environment: environment,
154154
CreatedAt: createdAt,
155155
Duration: duration,
@@ -159,9 +159,8 @@ func printTestExecutionsTable(w io.Writer, txs []*models.TestexecutionsQueryResu
159159
return tab.Flush()
160160
}
161161

162-
func truncateTestName(tn string) string {
163-
N := 48
164-
if len(tn) > N {
162+
func truncateTestName(tn string, N int) string {
163+
if len(tn) > N && N > 3 {
165164
start := len(tn) - (N - 3)
166165
return "..." + tn[start:]
167166
}

internal/command/smarttest/run_output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (o *defaultRunOutput) renderTestXsTable(txs []*models.TestExecution, runnin
107107
icon = "⚪"
108108
statusText = tx.Status.Phase
109109
}
110-
fmt.Fprintf(tw, "%s\t%s\t[ID: %s, STATUS: %s]\n", icon, tx.Spec.External.TestName,
110+
fmt.Fprintf(tw, "%s\t%s\t[ID: %s, STATUS: %s]\n", icon, truncateTestName(tx.Spec.External.TestName, 48),
111111
tx.ID, statusText)
112112
}
113113
tw.Flush()

0 commit comments

Comments
 (0)