Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: testing: allow regexps to specify example output #18831

Closed
posener opened this issue Jan 28, 2017 · 9 comments
Closed

proposal: testing: allow regexps to specify example output #18831

posener opened this issue Jan 28, 2017 · 9 comments

Comments

@posener
Copy link

posener commented Jan 28, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.7.4 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eyal/go:/home/eyal/home/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build162642716=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

Wrote a testable example.

What did you expect to see?

A possibility to define Output lines with a regular expression.

What did you see instead?

Only plan text is supported.

@mvdan
Copy link
Member

mvdan commented Jan 28, 2017

Why do you need this, exactly? Is the plaintext output too big or non-deterministic?

The point of output lines is readability and simplicity, and I think regexes would just add complexity.

@posener
Copy link
Author

posener commented Jan 28, 2017

I have a program that part of the output there is a time duration, that i would like to give an example for.
I think that making a regular expression optional won't harm anything in the simplicity of the example tests.
In the current example system I can't test this program.

@ALTree
Copy link
Member

ALTree commented Jan 28, 2017

Note that you'll also need to introduce an alternative prefix (not Output:) or you'll break existing tests for people that for example wrote Output: \d expecting a literal match with "\d".

@minux
Copy link
Member

minux commented Jan 29, 2017 via email

@posener
Copy link
Author

posener commented Jan 29, 2017

I saw in the code that there is unsorted option for the output, you use it by prefixing the output: unsorted Output:. (it is not documented)
We could do something similar, so it won't break non-regex output.

@rsc
Copy link
Contributor

rsc commented Jan 30, 2017

I think we'd prefer not to further complicate output tests. Doing something like replacing the time with "TIMESTAMP" in the output would be better. Or just don't print it in the first place.

@rsc rsc changed the title proposal: [testable example] write expected output using regular expressions proposal: testing: allow regexps to specify example output Jan 30, 2017
@rsc rsc added the Proposal label Jan 30, 2017
@rsc rsc added this to the Proposal milestone Jan 30, 2017
@bradfitz
Copy link
Contributor

I also don't want to do anything here. The whole point of examples to be simple.

Once you need a way to normalize the output, you've already failed at being simple.

@rsc
Copy link
Contributor

rsc commented Jan 30, 2017

Declining for @golang/proposal-review

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/36050 mentions this issue.

@golang golang locked and limited conversation to collaborators Jan 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants