Skip to content

test: check ctx in TestExecuteContextSystemTimeout instead of err#272

Merged
benhoyt merged 2 commits intobenhoyt:masterfrom
andrea-berling:patch-1
Feb 24, 2026
Merged

test: check ctx in TestExecuteContextSystemTimeout instead of err#272
benhoyt merged 2 commits intobenhoyt:masterfrom
andrea-berling:patch-1

Conversation

@andrea-berling
Copy link
Copy Markdown
Contributor

As mentioned in the comment, a return value of nil instead of DeadlineExceeded will make the test fail, so we don't run the test on those platform. Sadly, this seems to be happening on Linux too (Arch Linux specifically), leading to failure to build and install from the AUR:

paru -S goawk-git
:: Resolving dependencies...
:: Calculating conflicts...
:: Calculating inner conflicts...

Aur (1)        Old Version     New Version     Make Only
aur/goawk-git  r625.be7e702-1  r558.01e7dd0-1  No

:: Proceed to review? [Y/n]:

:: Downloading PKGBUILDs...
 PKGBUILDs up to date
 nothing new to review
fetching devel info...
==> Making package: goawk-git r558.01e7dd0-1 (Mon 23 Feb 2026 12:23:18 PM CET)
==> Retrieving sources...
  -> Updating goawk-git git repo...
==> Validating source files with md5sums...
    goawk-git ... Skipped
==> Making package: goawk-git r558.01e7dd0-1 (Mon 23 Feb 2026 12:23:20 PM CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating goawk-git git repo...
==> Validating source files with md5sums...
    goawk-git ... Skipped
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Creating working copy of goawk-git git repo...
Cloning into 'goawk-git'...
done.
==> Starting pkgver()...
==> Updated version: goawk-git r633.51baa3e-1
==> Sources are ready.
goawk-git-r558.01e7dd0-1: parsing pkg list...
==> Making package: goawk-git r633.51baa3e-1 (Mon 23 Feb 2026 12:23:24 PM CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
==> Starting check()...
ok      github.com/benhoyt/goawk        1.139s
ok      github.com/benhoyt/goawk/internal/ast   (cached)
ok      github.com/benhoyt/goawk/internal/compiler      (cached)
ok      github.com/benhoyt/goawk/internal/cover 0.003s
ok      github.com/benhoyt/goawk/internal/parseutil     (cached)
ok      github.com/benhoyt/goawk/internal/resolver      (cached)
265
--- FAIL: TestExecuteContextSystemTimeout (0.01s)
    newexecute_test.go:183: expected DeadlineExceeded error, got: <nil>
FAIL
FAIL    github.com/benhoyt/goawk/interp 1.913s
ok      github.com/benhoyt/goawk/lexer  (cached)
ok      github.com/benhoyt/goawk/parser (cached)
?       github.com/benhoyt/goawk/scripts/csvbench/count [no test files]
?       github.com/benhoyt/goawk/scripts/csvbench/write [no test files]
FAIL
==> ERROR: A failure occurred in check().
    Aborting...
error: failed to build 'goawk-git-r558.01e7dd0-1':
error: packages failed to build: goawk-git-r558.01e7dd0-1

For context, the build is failing after trying to run the following bash function:

check() {
  cd "$pkgname-$pkgver"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

  go test ./...
}

Since it's failing to run on linux too and it's already skipped on the other platforms, I elected to remove the whole test altogether. Actually fixing the actual test is a bit out of my knowledge level and bandwidth at the moment.

Lmk what you think 🙂

@benhoyt
Copy link
Copy Markdown
Owner

benhoyt commented Feb 23, 2026

Hmm, yes, I'd prefer we understand what's going on rather than removing the whole test. However, what about a compromise -- instead of removing the test, we change the err check to if err != nil && !errors.Is(err, context.DeadlineExceeded) { ... } with a comment explaining that it's sometimes nil on some platforms, particularly Windows and macOS. In other words, allow the error to either be nil or DeadlineExceeded.

@andrea-berling
Copy link
Copy Markdown
Contributor Author

@benhoyt alright, I decided to fold under zero pressure and actually look into this: apparently it's a known quirk of Go, where the os/exec package will not forward the ContextDeadline as an err to the caller. Instead, the err will be something like process killed or even nil, and the DeadlineExceeded error is actually to be found in ctx.Err(). See this thread: golang/go#21880. Pushed a fix that should work on all platforms (which I can't test because I don't have all platforms handy for testing. Works on my machine though 😁)

Copy link
Copy Markdown
Owner

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm happy with that.

@benhoyt benhoyt changed the title chore: remove TestExecuteContextSystemTimeout test test: check ctx in TestExecuteContextSystemTimeout instead of err Feb 24, 2026
@benhoyt benhoyt merged commit a1e0740 into benhoyt:master Feb 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants