Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ba68e40 authored by Jeongik Cha's avatar Jeongik Cha
Browse files

Show ETA only if it is smart status

To prevent breakage in parsing logic in build bot

Test: m
Bug: 313981966
Change-Id: Ib785bd1cf0fec92d9a4cf20ab8a33ae9590282a9
parent adbdbc33
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import (
type formatter struct {
	format string
	quiet  bool
	smart  bool
	start  time.Time
}

@@ -32,10 +33,11 @@ type formatter struct {
// the terminal in a format similar to Ninja.
// format takes nearly all the same options as NINJA_STATUS.
// %c is currently unsupported.
func newFormatter(format string, quiet bool) formatter {
func newFormatter(format string, quiet bool, smart bool) formatter {
	return formatter{
		format: format,
		quiet:  quiet,
		smart:  smart,
		start:  time.Now(),
	}
}
@@ -61,8 +63,9 @@ func remainingTimeString(t time.Time) string {
func (s formatter) progress(counts status.Counts) string {
	if s.format == "" {
		output := fmt.Sprintf("[%3d%% %d/%d", 100*counts.FinishedActions/counts.TotalActions, counts.FinishedActions, counts.TotalActions)

		if !counts.EstimatedTime.IsZero() {
		// Not to break parsing logic in the build bot
		// TODO(b/313981966): make buildbot more flexible for output format
		if s.smart && !counts.EstimatedTime.IsZero() {
			output += fmt.Sprintf(" %s remaining", remainingTimeString(counts.EstimatedTime))
		}
		output += "] "
+3 −2
Original line number Diff line number Diff line
@@ -27,9 +27,10 @@ import (
// statusFormat takes nearly all the same options as NINJA_STATUS.
// %c is currently unsupported.
func NewStatusOutput(w io.Writer, statusFormat string, forceSimpleOutput, quietBuild, forceKeepANSI bool) status.StatusOutput {
	formatter := newFormatter(statusFormat, quietBuild)
	useSmartStatus := !forceSimpleOutput && isSmartTerminal(w)
	formatter := newFormatter(statusFormat, quietBuild, useSmartStatus)

	if !forceSimpleOutput && isSmartTerminal(w) {
	if useSmartStatus {
		return NewSmartStatusOutput(w, formatter)
	} else {
		return NewSimpleStatusOutput(w, formatter, forceKeepANSI)