distributable:
  url: https://github.com/rogpeppe/go-internal/archive/refs/tags/{{ version.tag }}.tar.gz
  strip-components: 1

versions:
  github: rogpeppe/go-internal

provides:
  - bin/testscript

build:
  dependencies:
    go.dev: ~1.21
  script:
    - go mod download
    - go build -v -trimpath -ldflags="$GO_LDFLAGS" -o '{{prefix}}/bin/testscript' ./cmd/testscript
  env:
    GO_LDFLAGS: [-s, -w]
    linux:
      # or segmentation fault
      # fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
      GO_LDFLAGS:
        - -buildmode=pie

test:
  dependencies:
    pkgx.sh: 1
  script:
    - run: test "$(pkgx $FIXTURE)" = "PASS"
      fixture:
        extname: txtar
        contents: |
          exec echo hello!
          stdout hello!

interprets:
  extensions: txtar
  args: testscript
