Fix output 6

This commit is contained in:
Tim Vaillancourt 2022-12-04 03:14:09 +01:00
parent bae5a55db1
commit c11b1939c2
2 changed files with 13 additions and 14 deletions

View File

@ -6,15 +6,10 @@ import (
"database/sql"
"fmt"
"log"
"os"
"os/exec"
"sync"
)
func isGitHubActions() bool {
return os.Getenv("GITHUB_ACTION") != ""
}
// Test represents a single test.
type Test struct {
Name string
@ -138,18 +133,18 @@ func (test *Test) Migrate(config Config, primary, replica *sql.DB) (err error) {
}
var wg sync.WaitGroup
stop := make(chan bool)
stopStdout := make(chan bool)
go func() {
defer wg.Done()
//if isGitHubActions() {
fmt.Printf("::group::%s stdout\n", test.Name)
//}
if isGitHubActions() {
fmt.Printf("::group::%s stdout\n", test.Name)
}
for {
select {
case <-stop:
//if isGitHubActions() {
fmt.Println("::endgroup::")
//}
case <-stopStdout:
if isGitHubActions() {
fmt.Println("::endgroup::")
}
return
default:
scanner := bufio.NewScanner(&stdout)
@ -162,7 +157,7 @@ func (test *Test) Migrate(config Config, primary, replica *sql.DB) (err error) {
wg.Add(1)
err = cmd.Wait()
stop <- true
stopStdout <- true
wg.Wait()
if err != nil {

View File

@ -85,6 +85,10 @@ func isExpectedFailureOutput(output io.Reader, expectedFailure string) bool {
return false
}
func isGitHubActions() bool {
return os.Getenv("GITHUB_ACTION") != ""
}
func pingAndGetGTIDExecuted(db *sql.DB, timeout time.Duration) (*mysql.UUIDSet, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()