Git Product home page Git Product logo

go-cmdtest's Issues

check exit codes

Allow tests to express that a command fails with a particular exit code.

I propose that the syntax be extended so that in addition to

cmd --> FAIL

one can instead write

cmd --> FAIL 2

(or any other integer) to specify the desired exit code.

Handle global path's in output?

Hi, i have test suite with absolute path in my stdout:

$ go-arch-lint check --project-path ${PWD}/test/check/project --arch-file invalid_spec.yml --output-color=false --> FAIL
...
[Archfile] path '$.components.not_exist.in': not found directories for 'not_exist' in '/home/neo/go/src/github.com/fe3dback/go-arch-lint/test/check/project/not_exist':
  14 |   main:
  15 |     in: .
...

image

This test will fall on all another computers, except my )
this lib have any option, to substitute variables in stdout, before comparing with real output?

I tried using ${PWD} but it didn't help.

build error on Plan 9: undefined: syscall.Errno

Hello,

I happened to notice that the github.com/google/go-cmdtest package has a compilation error when targeting the Plan 9 operating system, which has three Go ports:

$ go tool dist list | grep plan9        
plan9/386
plan9/amd64
plan9/arm

The build error can be reproduced on another platform via cross-compilation, for example:

$ GOOS=plan9 GOARCH=amd64 go build ./...
# github.com/google/go-cmdtest
./cmdtest.go:536:17: undefined: syscall.Errno
$ echo $?
1

cmdtest.go imports "syscall" but the API of that package is system-specific. Its documentation says:

On most systems, that error has type syscall.Errno.

But isn't the case on Plan 9.

I don't use Plan 9 myself, but I noticed this when checking that another project (golang.org/x/vuln) at minimum compiles on all Go ports, and that project has go-cmdtest as a dependency. That project doesn't necessarily need to work on Plan 9 and can work around it, so this isn't causing a serious problem for it.

I'm reporting it here in case you find this information useful. If supporting Plan 9 is completely out of scope of go-cmdtest, you can leave the build error on Plan 9 as is and close this issue as not planned.

Thanks.

Handle different mount points when generating output via update feature

The problem

Currently, I can't update my ct files' outputs.

The reason

My /tmp is mounted at a different mount point than where my *.ct files are. Therefore, when updating them (by passing true as second argument to (*TestSuite).Run), I get the following error:

rename /tmp/cmdtest196280009 <my-ct-file-at-different-mount-than-tmp>: invalid cross-device link

This is due to using os.Rename to do the copy, which can't handle different mount points.

This happens because os.Rename uses the rename syscall under the hood, which, in its manual page, states:

(...) Linux permits a filesystem to be mounted at multiple points, but rename() does not work across different mount points, even if the same filesystem is mounted on both.

The solution

A possible solution would be to create, copy and remove the file in separate steps, which will avoid calling the rename syscall.


Nonetheless, great work so far, thanks!

Previous commands preventing new commands from running correctly.

I have setup a basic cobra CLI and found if you run if you run cmd --help before cmd --version the command returns help rather than version output. Suggesting that some of the state is being carried over between commands.

CT that functions as expected

$ cmd --version

CT that doesn't function as expected

$ cmd --help
...
$ cmd --version
...

Is there any way to prevent this or is this a bug with cobra?

I have set up an example repo:
https://github.com/Brookke/go-cmdtest-repo/blob/main/testdata/version.ct

I have also tried splitting up the commands into their own ct files, but still seeing the same issue.

Filtering output support

Hey ๐Ÿ‘‹

Been using your package here to try to write some cli integration tests for my project box and am running into a few issues that I think could be solved by implementing support for filtering output with either regular expressions or glob patterns.

See for example Mercurial's test runner and the section on Filtering output

Would you consider adding this support? ๐Ÿค”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.