Add collapsible stdout
This commit is contained in:
parent
b45947e974
commit
34646f553d
@ -1,11 +1,15 @@
|
|||||||
package localtests
|
package localtests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test represents a single test.
|
// Test represents a single test.
|
||||||
@ -126,12 +130,22 @@ func (test *Test) Migrate(config Config, primary, replica *sql.DB) (err error) {
|
|||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
cmd.Stdout = &output
|
cmd.Stdout = &output
|
||||||
|
|
||||||
|
if strings.TrimSpace(os.Getenv("GITHUB_ACTION")) == "true" {
|
||||||
|
go func(reader io.Reader) {
|
||||||
|
scanner := bufio.NewScanner(output)
|
||||||
|
fmt.Printf("::group::%s stdout\n", test.Name)
|
||||||
|
for scanner.Scan() {
|
||||||
|
fmt.Println(scanner.Text())
|
||||||
|
}
|
||||||
|
fmt.Println("::endgroup::")
|
||||||
|
}(&output)
|
||||||
|
}
|
||||||
|
|
||||||
if err = cmd.Run(); err != nil {
|
if err = cmd.Run(); err != nil {
|
||||||
if isExpectedFailureOutput(&stderr, test.ExpectedFailure) {
|
if isExpectedFailureOutput(&stderr, test.ExpectedFailure) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
output.Write(stderr.Bytes())
|
log.Printf("[%s] test failed: %+v", test.Name, stderr.String())
|
||||||
log.Printf("[%s] test failed: %+v", test.Name, output.String())
|
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user