diff options
author | 2020-07-28 17:49:01 +0000 | |
---|---|---|
committer | 2020-07-28 20:25:03 +0000 | |
commit | f445ba17882c159d1f676d81b1836f011051aa44 (patch) | |
tree | 94d32c438842f21ac9719d9a002f7c6403ef5ab6 | |
parent | 8ffde8c9d51810b3090ea85ccba415c9f4641afa (diff) |
Inclusive fix: renaming dumb terminal to simple terminal.
Bug: b/161896447
Test: "lunch 1" and "m nothing"
Change-Id: Ifb228c0f0f634477932c9240e57170f7390201f7
-rw-r--r-- | cmd/soong_ui/main.go | 40 | ||||
-rw-r--r-- | ui/build/upload.go | 4 | ||||
-rw-r--r-- | ui/terminal/Android.bp | 2 | ||||
-rw-r--r-- | ui/terminal/simple_status.go (renamed from ui/terminal/dumb_status.go) | 18 | ||||
-rw-r--r-- | ui/terminal/status.go | 6 | ||||
-rw-r--r-- | ui/terminal/status_test.go | 92 |
6 files changed, 81 insertions, 81 deletions
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go index e485c60e0..69e4f696c 100644 --- a/cmd/soong_ui/main.go +++ b/cmd/soong_ui/main.go @@ -35,14 +35,14 @@ import ( // A command represents an operation to be executed in the soong build // system. type command struct { - // the flag name (must have double dashes) + // The flag name (must have double dashes). flag string - // description for the flag (to display when running help) + // Description for the flag (to display when running help). description string - // Forces the status output into dumb terminal mode. - forceDumbOutput bool + // Stream the build status output into the simple terminal mode. + simpleOutput bool // Sets a prefix string to use for filenames of log files. logsPrefix string @@ -70,21 +70,21 @@ var commands []command = []command{ stdio: stdio, run: make, }, { - flag: "--dumpvar-mode", - description: "print the value of the legacy make variable VAR to stdout", - forceDumbOutput: true, - logsPrefix: "dumpvars-", - config: dumpVarConfig, - stdio: customStdio, - run: dumpVar, + flag: "--dumpvar-mode", + description: "print the value of the legacy make variable VAR to stdout", + simpleOutput: true, + logsPrefix: "dumpvars-", + config: dumpVarConfig, + stdio: customStdio, + run: dumpVar, }, { - flag: "--dumpvars-mode", - description: "dump the values of one or more legacy make variables, in shell syntax", - forceDumbOutput: true, - logsPrefix: "dumpvars-", - config: dumpVarConfig, - stdio: customStdio, - run: dumpVars, + flag: "--dumpvars-mode", + description: "dump the values of one or more legacy make variables, in shell syntax", + simpleOutput: true, + logsPrefix: "dumpvars-", + config: dumpVarConfig, + stdio: customStdio, + run: dumpVars, }, { flag: "--build-mode", description: "build modules based on the specified build action", @@ -125,7 +125,7 @@ func main() { os.Exit(1) } - output := terminal.NewStatusOutput(c.stdio().Stdout(), os.Getenv("NINJA_STATUS"), c.forceDumbOutput, + output := terminal.NewStatusOutput(c.stdio().Stdout(), os.Getenv("NINJA_STATUS"), c.simpleOutput, build.OsEnvironment().IsEnvTrue("ANDROID_QUIET_BUILD")) log := logger.New(output) @@ -172,7 +172,7 @@ func main() { buildErrorFile := filepath.Join(logsDir, c.logsPrefix+"build_error") rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb") soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics") - defer build.UploadMetrics(buildCtx, config, c.forceDumbOutput, buildStarted, buildErrorFile, rbeMetricsFile, soongMetricsFile) + defer build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, buildErrorFile, rbeMetricsFile, soongMetricsFile) os.MkdirAll(logsDir, 0777) log.SetOutput(filepath.Join(logsDir, c.logsPrefix+"soong.log")) diff --git a/ui/build/upload.go b/ui/build/upload.go index 1cc2e940c..a9346e0c5 100644 --- a/ui/build/upload.go +++ b/ui/build/upload.go @@ -44,7 +44,7 @@ var ( // environment variable. The metrics files are copied to a temporary directory // and the uploader is then executed in the background to allow the user to continue // working. -func UploadMetrics(ctx Context, config Config, forceDumbOutput bool, buildStarted time.Time, files ...string) { +func UploadMetrics(ctx Context, config Config, simpleOutput bool, buildStarted time.Time, files ...string) { ctx.BeginTrace(metrics.RunSetupTool, "upload_metrics") defer ctx.EndTrace() @@ -105,7 +105,7 @@ func UploadMetrics(ctx Context, config Config, forceDumbOutput bool, buildStarte // Start the uploader in the background as it takes several milliseconds to start the uploader // and prepare the metrics for upload. This affects small commands like "lunch". cmd := Command(ctx, config, "upload metrics", uploader, "--upload-metrics", pbFile) - if forceDumbOutput { + if simpleOutput { cmd.RunOrFatal() } else { cmd.RunAndStreamOrFatal() diff --git a/ui/terminal/Android.bp b/ui/terminal/Android.bp index b533b0d30..aa6e35d2b 100644 --- a/ui/terminal/Android.bp +++ b/ui/terminal/Android.bp @@ -17,7 +17,7 @@ bootstrap_go_package { pkgPath: "android/soong/ui/terminal", deps: ["soong-ui-status"], srcs: [ - "dumb_status.go", + "simple_status.go", "format.go", "smart_status.go", "status.go", diff --git a/ui/terminal/dumb_status.go b/ui/terminal/simple_status.go index 201770fac..4e8c56804 100644 --- a/ui/terminal/dumb_status.go +++ b/ui/terminal/simple_status.go @@ -21,31 +21,31 @@ import ( "android/soong/ui/status" ) -type dumbStatusOutput struct { +type simpleStatusOutput struct { writer io.Writer formatter formatter } -// NewDumbStatusOutput returns a StatusOutput that represents the +// NewSimpleStatusOutput returns a StatusOutput that represents the // current build status similarly to Ninja's built-in terminal // output. -func NewDumbStatusOutput(w io.Writer, formatter formatter) status.StatusOutput { - return &dumbStatusOutput{ +func NewSimpleStatusOutput(w io.Writer, formatter formatter) status.StatusOutput { + return &simpleStatusOutput{ writer: w, formatter: formatter, } } -func (s *dumbStatusOutput) Message(level status.MsgLevel, message string) { +func (s *simpleStatusOutput) Message(level status.MsgLevel, message string) { if level >= status.StatusLvl { fmt.Fprintln(s.writer, s.formatter.message(level, message)) } } -func (s *dumbStatusOutput) StartAction(action *status.Action, counts status.Counts) { +func (s *simpleStatusOutput) StartAction(action *status.Action, counts status.Counts) { } -func (s *dumbStatusOutput) FinishAction(result status.ActionResult, counts status.Counts) { +func (s *simpleStatusOutput) FinishAction(result status.ActionResult, counts status.Counts) { str := result.Description if str == "" { str = result.Command @@ -63,9 +63,9 @@ func (s *dumbStatusOutput) FinishAction(result status.ActionResult, counts statu } } -func (s *dumbStatusOutput) Flush() {} +func (s *simpleStatusOutput) Flush() {} -func (s *dumbStatusOutput) Write(p []byte) (int, error) { +func (s *simpleStatusOutput) Write(p []byte) (int, error) { fmt.Fprint(s.writer, string(p)) return len(p), nil } diff --git a/ui/terminal/status.go b/ui/terminal/status.go index 60dfc7025..d8e739211 100644 --- a/ui/terminal/status.go +++ b/ui/terminal/status.go @@ -26,12 +26,12 @@ import ( // // statusFormat takes nearly all the same options as NINJA_STATUS. // %c is currently unsupported. -func NewStatusOutput(w io.Writer, statusFormat string, forceDumbOutput, quietBuild bool) status.StatusOutput { +func NewStatusOutput(w io.Writer, statusFormat string, forceSimpleOutput, quietBuild bool) status.StatusOutput { formatter := newFormatter(statusFormat, quietBuild) - if !forceDumbOutput && isSmartTerminal(w) { + if !forceSimpleOutput && isSmartTerminal(w) { return NewSmartStatusOutput(w, formatter) } else { - return NewDumbStatusOutput(w, formatter) + return NewSimpleStatusOutput(w, formatter) } } diff --git a/ui/terminal/status_test.go b/ui/terminal/status_test.go index 9f6082988..aa69dff53 100644 --- a/ui/terminal/status_test.go +++ b/ui/terminal/status_test.go @@ -26,64 +26,64 @@ import ( func TestStatusOutput(t *testing.T) { tests := []struct { - name string - calls func(stat status.StatusOutput) - smart string - dumb string + name string + calls func(stat status.StatusOutput) + smart string + simple string }{ { - name: "two actions", - calls: twoActions, - smart: "\r\x1b[1m[ 0% 0/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action2\x1b[0m\x1b[K\r\x1b[1m[100% 2/2] action2\x1b[0m\x1b[K\n", - dumb: "[ 50% 1/2] action1\n[100% 2/2] action2\n", + name: "two actions", + calls: twoActions, + smart: "\r\x1b[1m[ 0% 0/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action2\x1b[0m\x1b[K\r\x1b[1m[100% 2/2] action2\x1b[0m\x1b[K\n", + simple: "[ 50% 1/2] action1\n[100% 2/2] action2\n", }, { - name: "two parallel actions", - calls: twoParallelActions, - smart: "\r\x1b[1m[ 0% 0/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 0% 0/2] action2\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action1\x1b[0m\x1b[K\r\x1b[1m[100% 2/2] action2\x1b[0m\x1b[K\n", - dumb: "[ 50% 1/2] action1\n[100% 2/2] action2\n", + name: "two parallel actions", + calls: twoParallelActions, + smart: "\r\x1b[1m[ 0% 0/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 0% 0/2] action2\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action1\x1b[0m\x1b[K\r\x1b[1m[100% 2/2] action2\x1b[0m\x1b[K\n", + simple: "[ 50% 1/2] action1\n[100% 2/2] action2\n", }, { - name: "action with output", - calls: actionsWithOutput, - smart: "\r\x1b[1m[ 0% 0/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action2\x1b[0m\x1b[K\r\x1b[1m[ 66% 2/3] action2\x1b[0m\x1b[K\noutput1\noutput2\n\r\x1b[1m[ 66% 2/3] action3\x1b[0m\x1b[K\r\x1b[1m[100% 3/3] action3\x1b[0m\x1b[K\n", - dumb: "[ 33% 1/3] action1\n[ 66% 2/3] action2\noutput1\noutput2\n[100% 3/3] action3\n", + name: "action with output", + calls: actionsWithOutput, + smart: "\r\x1b[1m[ 0% 0/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action2\x1b[0m\x1b[K\r\x1b[1m[ 66% 2/3] action2\x1b[0m\x1b[K\noutput1\noutput2\n\r\x1b[1m[ 66% 2/3] action3\x1b[0m\x1b[K\r\x1b[1m[100% 3/3] action3\x1b[0m\x1b[K\n", + simple: "[ 33% 1/3] action1\n[ 66% 2/3] action2\noutput1\noutput2\n[100% 3/3] action3\n", }, { - name: "action with output without newline", - calls: actionsWithOutputWithoutNewline, - smart: "\r\x1b[1m[ 0% 0/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action2\x1b[0m\x1b[K\r\x1b[1m[ 66% 2/3] action2\x1b[0m\x1b[K\noutput1\noutput2\n\r\x1b[1m[ 66% 2/3] action3\x1b[0m\x1b[K\r\x1b[1m[100% 3/3] action3\x1b[0m\x1b[K\n", - dumb: "[ 33% 1/3] action1\n[ 66% 2/3] action2\noutput1\noutput2\n[100% 3/3] action3\n", + name: "action with output without newline", + calls: actionsWithOutputWithoutNewline, + smart: "\r\x1b[1m[ 0% 0/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action2\x1b[0m\x1b[K\r\x1b[1m[ 66% 2/3] action2\x1b[0m\x1b[K\noutput1\noutput2\n\r\x1b[1m[ 66% 2/3] action3\x1b[0m\x1b[K\r\x1b[1m[100% 3/3] action3\x1b[0m\x1b[K\n", + simple: "[ 33% 1/3] action1\n[ 66% 2/3] action2\noutput1\noutput2\n[100% 3/3] action3\n", }, { - name: "action with error", - calls: actionsWithError, - smart: "\r\x1b[1m[ 0% 0/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action2\x1b[0m\x1b[K\r\x1b[1m[ 66% 2/3] action2\x1b[0m\x1b[K\nFAILED: f1 f2\ntouch f1 f2\nerror1\nerror2\n\r\x1b[1m[ 66% 2/3] action3\x1b[0m\x1b[K\r\x1b[1m[100% 3/3] action3\x1b[0m\x1b[K\n", - dumb: "[ 33% 1/3] action1\n[ 66% 2/3] action2\nFAILED: f1 f2\ntouch f1 f2\nerror1\nerror2\n[100% 3/3] action3\n", + name: "action with error", + calls: actionsWithError, + smart: "\r\x1b[1m[ 0% 0/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action1\x1b[0m\x1b[K\r\x1b[1m[ 33% 1/3] action2\x1b[0m\x1b[K\r\x1b[1m[ 66% 2/3] action2\x1b[0m\x1b[K\nFAILED: f1 f2\ntouch f1 f2\nerror1\nerror2\n\r\x1b[1m[ 66% 2/3] action3\x1b[0m\x1b[K\r\x1b[1m[100% 3/3] action3\x1b[0m\x1b[K\n", + simple: "[ 33% 1/3] action1\n[ 66% 2/3] action2\nFAILED: f1 f2\ntouch f1 f2\nerror1\nerror2\n[100% 3/3] action3\n", }, { - name: "action with empty description", - calls: actionWithEmptyDescription, - smart: "\r\x1b[1m[ 0% 0/1] command1\x1b[0m\x1b[K\r\x1b[1m[100% 1/1] command1\x1b[0m\x1b[K\n", - dumb: "[100% 1/1] command1\n", + name: "action with empty description", + calls: actionWithEmptyDescription, + smart: "\r\x1b[1m[ 0% 0/1] command1\x1b[0m\x1b[K\r\x1b[1m[100% 1/1] command1\x1b[0m\x1b[K\n", + simple: "[100% 1/1] command1\n", }, { - name: "messages", - calls: actionsWithMessages, - smart: "\r\x1b[1m[ 0% 0/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action1\x1b[0m\x1b[K\r\x1b[1mstatus\x1b[0m\x1b[K\r\x1b[Kprint\nFAILED: error\n\r\x1b[1m[ 50% 1/2] action2\x1b[0m\x1b[K\r\x1b[1m[100% 2/2] action2\x1b[0m\x1b[K\n", - dumb: "[ 50% 1/2] action1\nstatus\nprint\nFAILED: error\n[100% 2/2] action2\n", + name: "messages", + calls: actionsWithMessages, + smart: "\r\x1b[1m[ 0% 0/2] action1\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action1\x1b[0m\x1b[K\r\x1b[1mstatus\x1b[0m\x1b[K\r\x1b[Kprint\nFAILED: error\n\r\x1b[1m[ 50% 1/2] action2\x1b[0m\x1b[K\r\x1b[1m[100% 2/2] action2\x1b[0m\x1b[K\n", + simple: "[ 50% 1/2] action1\nstatus\nprint\nFAILED: error\n[100% 2/2] action2\n", }, { - name: "action with long description", - calls: actionWithLongDescription, - smart: "\r\x1b[1m[ 0% 0/2] action with very long descrip\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action with very long descrip\x1b[0m\x1b[K\n", - dumb: "[ 50% 1/2] action with very long description to test eliding\n", + name: "action with long description", + calls: actionWithLongDescription, + smart: "\r\x1b[1m[ 0% 0/2] action with very long descrip\x1b[0m\x1b[K\r\x1b[1m[ 50% 1/2] action with very long descrip\x1b[0m\x1b[K\n", + simple: "[ 50% 1/2] action with very long description to test eliding\n", }, { - name: "action with output with ansi codes", - calls: actionWithOuptutWithAnsiCodes, - smart: "\r\x1b[1m[ 0% 0/1] action1\x1b[0m\x1b[K\r\x1b[1m[100% 1/1] action1\x1b[0m\x1b[K\n\x1b[31mcolor\x1b[0m\n", - dumb: "[100% 1/1] action1\ncolor\n", + name: "action with output with ansi codes", + calls: actionWithOuptutWithAnsiCodes, + smart: "\r\x1b[1m[ 0% 0/1] action1\x1b[0m\x1b[K\r\x1b[1m[100% 1/1] action1\x1b[0m\x1b[K\n\x1b[31mcolor\x1b[0m\n", + simple: "[100% 1/1] action1\ncolor\n", }, } @@ -103,24 +103,24 @@ func TestStatusOutput(t *testing.T) { } }) - t.Run("dumb", func(t *testing.T) { - dumb := &bytes.Buffer{} - stat := NewStatusOutput(dumb, "", false, false) + t.Run("simple", func(t *testing.T) { + simple := &bytes.Buffer{} + stat := NewStatusOutput(simple, "", false, false) tt.calls(stat) stat.Flush() - if g, w := dumb.String(), tt.dumb; g != w { + if g, w := simple.String(), tt.simple; g != w { t.Errorf("want:\n%q\ngot:\n%q", w, g) } }) - t.Run("force dumb", func(t *testing.T) { + t.Run("force simple", func(t *testing.T) { smart := &fakeSmartTerminal{termWidth: 40} stat := NewStatusOutput(smart, "", true, false) tt.calls(stat) stat.Flush() - if g, w := smart.String(), tt.dumb; g != w { + if g, w := smart.String(), tt.simple; g != w { t.Errorf("want:\n%q\ngot:\n%q", w, g) } }) |