tools: Add --filename-column-width to test runner
If provided, this option truncates long filenames to avoid unpleasant line wrapping behavior for those of us that use narrow terminals. Change-Id: I684b91b7aa4b0ae86a4cf9ed9f047b685ab97550 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57100 Auto-Submit: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
9545fb76b6
commit
facb5ced00
|
@ -71,6 +71,7 @@ optional flags:`)
|
||||||
|
|
||||||
func run() error {
|
func run() error {
|
||||||
var formatList, filter, dxcPath, xcrunPath string
|
var formatList, filter, dxcPath, xcrunPath string
|
||||||
|
var maxFilenameColumnWidth int
|
||||||
numCPU := runtime.NumCPU()
|
numCPU := runtime.NumCPU()
|
||||||
fxc, verbose, generateExpected, generateSkip := false, false, false, false
|
fxc, verbose, generateExpected, generateSkip := false, false, false, false
|
||||||
flag.StringVar(&formatList, "format", "all", "comma separated list of formats to emit. Possible values are: all, wgsl, spvasm, msl, hlsl")
|
flag.StringVar(&formatList, "format", "all", "comma separated list of formats to emit. Possible values are: all, wgsl, spvasm, msl, hlsl")
|
||||||
|
@ -82,6 +83,7 @@ func run() error {
|
||||||
flag.BoolVar(&generateExpected, "generate-expected", false, "create or update all expected outputs")
|
flag.BoolVar(&generateExpected, "generate-expected", false, "create or update all expected outputs")
|
||||||
flag.BoolVar(&generateSkip, "generate-skip", false, "create or update all expected outputs that fail with SKIP")
|
flag.BoolVar(&generateSkip, "generate-skip", false, "create or update all expected outputs that fail with SKIP")
|
||||||
flag.IntVar(&numCPU, "j", numCPU, "maximum number of concurrent threads to run tests")
|
flag.IntVar(&numCPU, "j", numCPU, "maximum number of concurrent threads to run tests")
|
||||||
|
flag.IntVar(&maxFilenameColumnWidth, "filename-column-width", 0, "maximum width of the filename column")
|
||||||
flag.Usage = showUsage
|
flag.Usage = showUsage
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
@ -260,6 +262,9 @@ func run() error {
|
||||||
// Print the table of file x format and gather per-format stats
|
// Print the table of file x format and gather per-format stats
|
||||||
failures := []failure{}
|
failures := []failure{}
|
||||||
filenameColumnWidth := maxStringLen(files)
|
filenameColumnWidth := maxStringLen(files)
|
||||||
|
if maxFilenameColumnWidth > 0 {
|
||||||
|
filenameColumnWidth = maxFilenameColumnWidth
|
||||||
|
}
|
||||||
|
|
||||||
red := color.New(color.FgRed)
|
red := color.New(color.FgRed)
|
||||||
green := color.New(color.FgGreen)
|
green := color.New(color.FgGreen)
|
||||||
|
@ -276,7 +281,7 @@ func run() error {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
printHorizontalLine := func() {
|
printHorizontalLine := func() {
|
||||||
fmt.Printf(strings.Repeat("━", maxStringLen(files)))
|
fmt.Printf(strings.Repeat("━", filenameColumnWidth))
|
||||||
fmt.Printf("━╋━")
|
fmt.Printf("━╋━")
|
||||||
for _, format := range formats {
|
for _, format := range formats {
|
||||||
fmt.Printf(strings.Repeat("━", formatWidth(format)))
|
fmt.Printf(strings.Repeat("━", formatWidth(format)))
|
||||||
|
@ -296,7 +301,13 @@ func run() error {
|
||||||
row := &strings.Builder{}
|
row := &strings.Builder{}
|
||||||
rowAllPassed := true
|
rowAllPassed := true
|
||||||
|
|
||||||
fmt.Fprintf(row, alignRight(file, filenameColumnWidth))
|
filenameLength := utf8.RuneCountInString(file)
|
||||||
|
shortFile := file
|
||||||
|
if filenameLength > filenameColumnWidth {
|
||||||
|
shortFile = "..." + file[filenameLength-filenameColumnWidth+3:]
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(row, alignRight(shortFile, filenameColumnWidth))
|
||||||
fmt.Fprintf(row, " ┃ ")
|
fmt.Fprintf(row, " ┃ ")
|
||||||
for _, format := range formats {
|
for _, format := range formats {
|
||||||
columnWidth := formatWidth(format)
|
columnWidth := formatWidth(format)
|
||||||
|
|
Loading…
Reference in New Issue