Remove "testing" import from public interface #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the DoTestCase, DoTestCaseFile, and DoTestCases functions,
are exposed as part of the public interface.
Implementing these functions requires importing the
testing
package.Importing the
testing
package automatically registers a number ofglobal command line flags.
The effect of this is that any application using the standard
flag
package with goldmark will automatically get a number of unwanted
command line flags. This is verifiable with the following program,
To fix this, the
testing
import needs to be removed from all non-testfiles. There are two ways to go about it,
interface with a subset of the methods of
testing.T
and switch thefunctions to consume that. This is what testing libraries like
gomock and testify do.
the public interface of the library and use them only from tests.
Since these functions are meant to be used by external extensions, I've
introduced a TestingT interface that is a subset of the functionality
provided by
testing.T
. It supports the standard operations: logging,skiping, and failing tests,
This also moves those functions into a testutil subpackage. This will help
keep the top-level goldmark package clean and limited to core functionality.
(Note that tests in the top-level goldmark package that make use of
these functions must now use the package name
goldmark_test
so thatthey're considered separate from the main
goldmark
package, otherwiseyou'll see an import cycle: goldmark imports testutil imports goldmark.)