Verify the reliability sprint and guard release checkout validation
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
@@ -10,11 +11,11 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
os.Exit(run())
|
||||
os.Exit(run(os.Args[1:], os.Stdout, os.Stderr))
|
||||
}
|
||||
|
||||
func run() int {
|
||||
func run(args []string, stdout, stderr io.Writer) int {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
return cli.Run(ctx, os.Args[1:], os.Stdout, os.Stderr)
|
||||
return cli.Run(ctx, args, stdout, stderr)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
@@ -41,10 +40,7 @@ func TestProcessSubprocessHelper(t *testing.T) {
|
||||
}
|
||||
syscall.Umask(int(mask))
|
||||
}
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
code := cli.Run(ctx, os.Args[i+1:], os.Stdout, os.Stderr)
|
||||
stop()
|
||||
os.Exit(code)
|
||||
os.Exit(run(os.Args[i+1:], os.Stdout, os.Stderr))
|
||||
}
|
||||
}
|
||||
os.Exit(2)
|
||||
@@ -237,7 +233,6 @@ type processFixture struct {
|
||||
dir string
|
||||
config string
|
||||
transcript string
|
||||
glossary string
|
||||
output string
|
||||
provider *fixtureProvider
|
||||
server *httptest.Server
|
||||
@@ -282,11 +277,8 @@ func newProcessFixture(t *testing.T, mode, modules string) processFixture {
|
||||
if err := os.WriteFile(transcript, []byte(`[{"id":1,"speaker":"A","start":0,"end":1,"text":"hello world"}]`), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
glossary := filepath.Join(dir, "glossary.yaml")
|
||||
if err := os.WriteFile(glossary, []byte("glossary:\n - name: Example\n category: product\n summary: A sample.\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return processFixture{dir: dir, config: configPath, transcript: transcript, glossary: glossary,
|
||||
|
||||
return processFixture{dir: dir, config: configPath, transcript: transcript,
|
||||
output: filepath.Join(dir, "output.json"), provider: p, server: server}
|
||||
}
|
||||
|
||||
@@ -314,25 +306,6 @@ func (f processFixture) run(t *testing.T, includeOutput bool, extra ...string) (
|
||||
return code, stdout.String(), stderr.String()
|
||||
}
|
||||
|
||||
func (f processFixture) runConfigView(t *testing.T, view string) (int, string, string) {
|
||||
t.Helper()
|
||||
command := exec.Command(os.Args[0], "-test.run=^TestProcessSubprocessHelper$", "--", "config", "print-effective", "--config", f.config, "--view", view)
|
||||
command.Dir = f.dir
|
||||
command.Env = append(os.Environ(), "AUDITA_HELPER_PROCESS=1", "AUDITA_TEST_PROVIDER_KEY="+f.provider.secret)
|
||||
var stdout, stderr bytes.Buffer
|
||||
command.Stdout, command.Stderr = &stdout, &stderr
|
||||
err := command.Run()
|
||||
code := 0
|
||||
if err != nil {
|
||||
if exit, ok := err.(*exec.ExitError); ok {
|
||||
code = exit.ExitCode()
|
||||
} else {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
return code, stdout.String(), stderr.String()
|
||||
}
|
||||
|
||||
func (f processFixture) errors(t *testing.T) reporting.ErrorsDocument {
|
||||
t.Helper()
|
||||
raw, err := os.ReadFile(filepath.Join(f.dir, "errors.yml"))
|
||||
@@ -879,7 +852,7 @@ func TestSubprocessReportingAndDebugSelections(t *testing.T) {
|
||||
for _, selection := range []struct{ reporting, debug bool }{
|
||||
{false, false}, {false, true}, {true, false}, {true, true},
|
||||
} {
|
||||
f := newProcessFixture(t, "repair-filter-later-failure", "[grammar, grammar]")
|
||||
f := newProcessFixture(t, "normal", "[grammar]")
|
||||
|
||||
reportDir := filepath.Join(f.dir, "missing")
|
||||
extra := []string{"--verbose", "--reporting=false", "--report-dir", reportDir}
|
||||
@@ -894,7 +867,7 @@ func TestSubprocessReportingAndDebugSelections(t *testing.T) {
|
||||
extra = append(extra, "--debug")
|
||||
}
|
||||
code, stdout, stderr := f.run(t, true, extra...)
|
||||
if code != 0 || stdout != "" || !strings.Contains(stderr, "1 corrections applied; 1 work units with errors; 1 recoveries") {
|
||||
if code != 0 || stdout != "" || !strings.Contains(stderr, "1 corrections applied; 0 work units with errors; 0 recoveries") {
|
||||
t.Fatalf("selection=%+v code=%d stdout=%q stderr=%q", selection, code, stdout, stderr)
|
||||
}
|
||||
output, err := os.ReadFile(f.output)
|
||||
@@ -1072,8 +1045,9 @@ func TestSubprocessCancellationLeavesFailedReportsWithoutTranscript(t *testing.T
|
||||
t.Fatal(err)
|
||||
}
|
||||
err := command.Wait()
|
||||
if ctx.Err() != nil || err == nil {
|
||||
t.Fatalf("cancellation did not stop run: %v %v stderr=%q", err, ctx.Err(), stderr.String())
|
||||
var exit *exec.ExitError
|
||||
if ctx.Err() != nil || !errors.As(err, &exit) || exit.ExitCode() != 1 {
|
||||
t.Fatalf("interrupt did not reach the failure exit: %v %v stderr=%q", err, ctx.Err(), stderr.String())
|
||||
}
|
||||
if document := f.errors(t); document.Status != reporting.StatusFailed || len(document.Errors) == 0 {
|
||||
t.Fatalf("cancellation report: %+v", document)
|
||||
@@ -1556,11 +1530,13 @@ func TestSubprocessEmitsProgressBeforeProviderReturns(t *testing.T) {
|
||||
case <-ctx.Done():
|
||||
t.Fatal("proposal progress did not reach stderr while the provider was blocked")
|
||||
}
|
||||
if err := cmd.Process.Signal(os.Interrupt); err != nil {
|
||||
if err := cmd.Process.Signal(syscall.SIGTERM); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := cmd.Wait(); err == nil || ctx.Err() != nil {
|
||||
t.Fatalf("interrupt did not complete the invocation: %v", err)
|
||||
err = cmd.Wait()
|
||||
var exit *exec.ExitError
|
||||
if !errors.As(err, &exit) || exit.ExitCode() != 1 || ctx.Err() != nil {
|
||||
t.Fatalf("termination did not reach the failure exit: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user