Skip to content

Redesign to support concurrency #27

@jacobsa

Description

@jacobsa

The current design of the ogletest package has the insidious global state of the currently running test. (This is implied by functions like ExpectEq, AddFailure, etc.) This makes it hard or impossible to add the feature of test parallelization.

Let's fix that:

  • Mirror the current state of the package to a new package with the too-cute name of ogretest, making it easy for existing tests that will otherwise be broken to fix themselves with a one-character change.
  • Make sure to document why this package exists, with advertisements saying it's deprecated, etc.
  • Add an ogletest.T type.
  • Fields:
    - Context
    - Mock controller
  • Methods:
    - AddFailure
    - ExpectThat, ExpectEq, ExpectLt, etc.
    - AbortTest, AssertThat, and friends, which we explicitly say must only be used on the test's original goroutine.
  • Test functions are functions that accept *ogletest.T.
  • Test suites have their functions inferred by looking for exported methods with that signature.
  • Special cases: SetUp(*ogletest.T), TearDown(*ogletest.T)
  • Leave up SetUpTestSuite and TearDownTestSuite for now.
  • Concurrency
  • Document that users must cope with concurrent execution.
  • No features for limiting this (for now anyway); users can build it on top if they need to.
  • --ogletest.parallelism flag for controlling parallelism. Default is GOMAXPROCS.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions