Skip to content

Cannot write command tests without shell (sh) #870

Open
@berney

Description

@berney

Describe the bug

Goss command test will execute the command wrapped with a sh -c "<the command>".
This assumes sh executable exists.
When testing distroless containers with a single binary, goss cannot execute the binary.

Dockerfile

FROM scratch
ADD figlet /
ENTRYPOINT ["figlet"]

goss.yaml

Command: figlet: exit-status:
Error
    exec: "sh": executable file not found in $PATH

How To Reproduce

Create a single statically compiled binary, or a binary with the needed libraries.
For me it is figlet.

command:
  figlet:
    exec: figlet test

Expected Behavior

Goss to directly execute (without a shell in the middle) figlet (arg 0) with single argument test (arg 1).

I think that goss giving a shell, should be configurable - and optional.
Perhaps a new attribute shell that defaults to sh, and if explicitly set to nothing shell:, then goss will exec directly the command, rather than running it in a shell.

Actual Behavior

Goss attempts to execute sh, which doesn't exist, so fails.

Environment:

  • Version of goss: goss version v0.4.4
  • OS/Distribution version (if applicable): Alpine Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions