Skip to content

testing: examples should run in source order #4662

Description

@rsc
Example tests should run in the same order they appear in the source file, just as with
ordinary tests.
It appears that non-method examples are run before method examples.

Activity

  1. rsc commented on Jan 15, 2013

    @rsc
    ContributorAuthor

    Comment 1:

    Also method examples are run in order sorted by method name, not source order.
  2. gopherbot commented on Jan 15, 2013

    @gopherbot
    Contributor

    Comment 2 by osaingre:

    > Also method examples are run in order sorted by method name, not source order.
    Hi, do you deem acceptable to remove the sort done in go.doc.Examples() ?
    After all, the order is not specified in the documentation.
  3. rsc commented on Jan 18, 2013

    @rsc
    ContributorAuthor

    Comment 3:

    Sorted by name is probably correct most of the time. However, it's not in this case. I
    would suggest adding a new field 
    Order int // original source order
    to the Example struct and let cmd/go sort by that.
  4. gopherbot commented on Jan 20, 2013

    @gopherbot
    Contributor

    Comment 4 by vegacom:

    since the sorting is done in example.go and not in test.go, I think removing the sort
    import and related code does the trick. https://golang.org/cl/7127064
    unless I'm missing something...
  5. rsc commented on Jan 22, 2013

    @rsc
    ContributorAuthor

    Comment 5:

    The sorting is done in package example. That can be used for things besides generating
    tests. I don't want to remove the "sorted order" guarantee that it currently makes. I
    just want to make it possible to reconstruct the original order.
  6. gopherbot commented on Jan 23, 2013

    @gopherbot
    Contributor

    Comment 6 by osaingre:

    Alright. I get it.
  7. gopherbot commented on Jan 27, 2013

    @gopherbot
    Contributor

    Comment 7 by vegacom:

    got it, dropped CL.
  8. rsc commented on Feb 2, 2013

    @rsc
    ContributorAuthor

    Comment 8:

    This issue was closed by revision 18178fd.

    Status changed to Fixed.

  9. added this to the Go1.1 milestone on Apr 14, 2015
  10. locked and limited conversation to collaborators on Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions