Skip to content

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

Closed

Description

@posener

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.

Activity

  1. mvdan commented on Jan 28, 2017

    @mvdan
    Member

    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.

  2. posener commented on Jan 28, 2017

    @posener
    Author

    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.

  3. ALTree commented on Jan 28, 2017

    @ALTree
    Member

    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".

  4. minux commented on Jan 29, 2017

    @minux
    Member
  5. posener commented on Jan 29, 2017

    @posener
    Author

    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.

  6. rsc commented on Jan 30, 2017

    @rsc
    Contributor

    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.

  7. changed the title [-]proposal: [testable example] write expected output using regular expressions[/-] [+]proposal: testing: allow regexps to specify example output[/+] on Jan 30, 2017
  8. added this to the Proposal milestone on Jan 30, 2017
  9. bradfitz commented on Jan 30, 2017

    @bradfitz
    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.

  10. rsc commented on Jan 30, 2017

    @rsc
    Contributor

    Declining for @golang/proposal-review

  11. gopherbot commented on Jan 31, 2017

    @gopherbot
    Contributor

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

  12. locked and limited conversation to collaborators on Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions