-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Feature/dcmtest package #201
Draft
bpeake-illuscio
wants to merge
14
commits into
suyashkumar:main
Choose a base branch
from
illuscio-dev:feature/dcmtest_package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Feature/dcmtest package #201
bpeake-illuscio
wants to merge
14
commits into
suyashkumar:main
from
illuscio-dev:feature/dcmtest_package
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hello!
Following up on #198, I started writing a standalone PR for the full-DICOM element equality roundtrip tests, and realized that some of the helpers I was building might be useful for public consumption (for instance, I would want them for testing some things that I am building). I always appreciate libs that expose test helpers where appropriate, and this seems like a place where exposing some internal helpers could possibly benefit other maintainers.
This is kind of a throw-something-new-against-the-wall Draft PR and see if it sticks. I totally understand if this isn't something you feel belongs in the lib.
Changes Overview
dcmtest Package Added
I've added a
/pkg/dcmtest
package and moved the old/testdata
folder into this package as a/pkg/dcmtest/data
sub-folder.Inside the dcmtest package, Ive used the new go 1.16 embed package to add a
dcmtest.IncludedFS
var that contains an embed.FS FS value which is an embedded filesystem containing all of our test files, so other packages can pull in our test files and use them in their own tests without worrying about finnicky test file paths. In theory, this should also make tests a teensy bit more performant as the test files may be kept in memory instead of read from disk each time, but I see this more as a collateral benefit than the driving purpose of ease-of-use for writing tests that consume real dicom files.This package also has a few test helpers like
dcmtest.WalkIncludedFS
anddcmtest.BenchIncludedFS
which can be used to automatically setup and run table tests against every DICOM file contained indcmtest.IncludedFS
.Here is an example of how that might look, using a re-written parse test from
parse_test.go
, which is also included in this PR:I've also included a more general pair of
dcmtest.WalkFS
anddcmtest.BenchFS
which take in an arbitraryfs.Fs
interface for if we or others want to add or use a different FileSystem with other datasets for their table tests. I like this because, in theory, you could wrap a PACS server API or a DICOMDIR in a fs.FS implementation and pass it to this helper function for running table-tests against your dataset.Bumped Go version to 1.16
I've altered the
go.mod
and Github Actions to use go 1.16 so we can gain access to the embed feature.Possible Concerns.
There is one major concern with this approach, if dcmtest is imported into a non-test file, it could significantly bloat binary
sizes. I have tried to mitigate this possibility by adding warning sections to the package that spell out this package should only be consumed by tests.
I also tested this to double-check that it will not inadvertently bloat binaries and confirmed that no binary bloat occurs when this package is only consumed by test files, even if the test file is part of the production package instead of a package_test companion package.
Next Steps
I'm going to open a couple more PRs based on this for the pydicom and read/write roundtrip tests, but again. If you're not sure about this I am more than happy to redo those without these changes.
Let me know what you think!