Merge branch 'master' of ssh://gogs.mikescher.com:8022/BlackForestBytes/goext

This commit is contained in:
Robin Willmann 2023-09-26 14:41:06 +02:00
commit 127764556e
5 changed files with 21 additions and 13 deletions

View File

@ -7,5 +7,11 @@ test:
which gotestsum || go install gotest.tools/gotestsum@latest which gotestsum || go install gotest.tools/gotestsum@latest
gotestsum --format "testname" -- -tags="timetzdata sqlite_fts5 sqlite_foreign_keys" "./..." gotestsum --format "testname" -- -tags="timetzdata sqlite_fts5 sqlite_foreign_keys" "./..."
test-in-docker:
tag="goext_temp_test_image:$(shell uuidgen | tr -d '-')"; \
docker build --tag $$tag . -f .gitea/workflows/Dockerfile_tests; \
docker run --rm $$tag; \
docker rmi $$tag
version: version:
_data/version.sh _data/version.sh

View File

@ -133,9 +133,6 @@ func run(opt CommandRunner) (CommandResult, error) {
case <-stderrFailChan: case <-stderrFailChan:
_ = cmd.Process.Kill() _ = cmd.Process.Kill()
for _, lstr := range opt.listener {
lstr.Timeout()
}
if fallback, ok := syncext.ReadChannelWithTimeout(outputChan, 32*time.Millisecond); ok { if fallback, ok := syncext.ReadChannelWithTimeout(outputChan, 32*time.Millisecond); ok {
// most of the time the cmd.Process.Kill() should also have finished the pipereader // most of the time the cmd.Process.Kill() should also have finished the pipereader
@ -160,7 +157,8 @@ func run(opt CommandRunner) (CommandResult, error) {
} }
case outobj := <-outputChan: case outobj := <-outputChan:
if exiterr, ok := outobj.err.(*exec.ExitError); ok { var exiterr *exec.ExitError
if errors.As(outobj.err, &exiterr) {
excode := exiterr.ExitCode() excode := exiterr.ExitCode()
for _, lstr := range opt.listener { for _, lstr := range opt.listener {
lstr.Finished(excode) lstr.Finished(excode)

View File

@ -32,8 +32,8 @@ func (pr *pipeReader) Read(listener []CommandListener) (string, string, string,
stdout := "" stdout := ""
go func() { go func() {
buf := make([]byte, 128) buf := make([]byte, 128)
for true { for {
n, out := pr.stdout.Read(buf) n, err := pr.stdout.Read(buf)
if n > 0 { if n > 0 {
txt := string(buf[:n]) txt := string(buf[:n])
stdout += txt stdout += txt
@ -42,11 +42,11 @@ func (pr *pipeReader) Read(listener []CommandListener) (string, string, string,
lstr.ReadRawStdout(buf[:n]) lstr.ReadRawStdout(buf[:n])
} }
} }
if out == io.EOF { if err == io.EOF {
break break
} }
if out != nil { if err != nil {
errch <- out errch <- err
break break
} }
} }
@ -61,7 +61,7 @@ func (pr *pipeReader) Read(listener []CommandListener) (string, string, string,
stderr := "" stderr := ""
go func() { go func() {
buf := make([]byte, 128) buf := make([]byte, 128)
for true { for {
n, err := pr.stderr.Read(buf) n, err := pr.stderr.Read(buf)
if n > 0 { if n > 0 {

View File

@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.270" const GoextVersion = "0.0.271"
const GoextVersionTimestamp = "2023-09-25T11:35:03+0200" const GoextVersionTimestamp = "2023-09-26T14:32:45+0200"

View File

@ -27,10 +27,12 @@ func (a *AtomicBool) Get() bool {
return a.v return a.v
} }
func (a *AtomicBool) Set(value bool) { func (a *AtomicBool) Set(value bool) bool {
a.lock.Lock() a.lock.Lock()
defer a.lock.Unlock() defer a.lock.Unlock()
oldValue := a.v
a.v = value a.v = value
for k, v := range a.listener { for k, v := range a.listener {
@ -42,6 +44,8 @@ func (a *AtomicBool) Set(value bool) {
delete(a.listener, k) delete(a.listener, k)
} }
} }
return oldValue
} }
func (a *AtomicBool) Wait(waitFor bool) { func (a *AtomicBool) Wait(waitFor bool) {