|
|
(41 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| This page documents how to add test data while developing ITK.
| | {{ Historical }} |
| See our [[ITK/Git|table of contents]] for more information.
| |
| __TOC__
| |
| = Workflow =
| |
|
| |
|
| Our workflow for adding data integrates with our standard Git [[ITK/Git/Develop|development process]].
| | Up to date information can be found on GitHub: |
| Start by [[ITK/Git/Develop#Create_a_Topic|creating a topic]].
| | https://github.com/InsightSoftwareConsortium/ITK/blob/master/Documentation/Data.md |
| Return here when you reach the "edit files" step.
| |
| | |
| == Add Data ==
| |
| | |
| {| style="width: 100%"
| |
| |-
| |
| |width=60%|
| |
| Copy the data file into your local source tree.
| |
| |-
| |
| |
| |
| :<code>$ mkdir -p Modules/.../test/Baseline</code>
| |
| :<code>$ cp ~/''MyTest.png'' Modules/.../test/Baseline/''MyTest.png''</code>
| |
| |
| |
| |}
| |
| | |
| == Add Test ==
| |
| | |
| {| style="width: 100%"
| |
| |-
| |
| |width=60%|
| |
| Edit the test CMakeLists.txt file and reference the data file in an itk_add_test call.
| |
| Specify the file inside <code>DATA{...}</code> using a path relative to the test directory:
| |
| :<code>$ edit Modules/.../test/CMakeLists.txt</code>
| |
| :{|
| |
| |
| |
| itk_add_test(NAME MyTest COMMAND ... --compare DATA{Baseline/''MyTest.png''} ...)
| |
| |}
| |
| |align="center"|
| |
| [http://itk.org/gitweb?p=ITK.git;a=blob;f=CMake/ExternalData.cmake;hb=HEAD <code>ExternalData.cmake</code>]
| |
| |}
| |
| | |
| == Run CMake ==
| |
| | |
| {| style="width: 100%"
| |
| |-
| |
| |width=60%|
| |
| Run cmake on the build tree:
| |
| :<code>$ cd ../ITK-build</code> | |
| :<code>$ cmake .</code>
| |
| :''(Or just run "make" to do a full configuration and build.)''
| |
| :<code>$ cd ../ITK</code>
| |
| |
| |
| |-
| |
| |
| |
| During configuration CMake will display a message such as:
| |
| :{|
| |
| |
| |
| Linked Modules/.../test/Baseline/''MyTest.png''.md5 to ExternalData MD5/...
| |
| |}
| |
| This means that CMake converted the file into a data object referenced by a "content link".
| |
| |align="center"|
| |
| [http://itk.org/gitweb?p=ITK.git;a=blob;f=CMake/ExternalData.cmake;hb=HEAD <code>ExternalData.cmake</code>]
| |
| |}
| |
| | |
| == Commit ==
| |
| | |
| {| style="width: 100%"
| |
| |-
| |
| |width=60%|
| |
| Continue to [[ITK/Git/Develop#Create_a_Topic|create the topic]] and edit other files as necessary.
| |
| Add the content link and commit it along with the other changes:
| |
| :<code>$ git add Modules/.../test/Baseline/''MyTest.png''.md5</code>
| |
| :<code>$ git add Modules/.../test/CMakeLists.txt</code>
| |
| :<code>$ git commit</code>
| |
| |align="center"|
| |
| [http://www.kernel.org/pub/software/scm/git/docs/git-add.html <code>git help add</code>]
| |
| <br/>
| |
| [http://www.kernel.org/pub/software/scm/git/docs/git-commit.html <code>git help commit</code>]
| |
| |-
| |
| |
| |
| The local <code>pre-commit</code> hook will display a message such as:
| |
| :{|
| |
| |
| |
| Content link Modules/.../test/Baseline/''MyTest.png''.md5 -> .ExternalData/MD5/...
| |
| |}
| |
| This means that the pre-commit hook recognized that the content link references a new data object and prepared it for upload.
| |
| |align="center"|
| |
| [http://itk.org/gitweb?p=ITK.git;a=blob;f=Utilities/Hooks/pre-commit;hb=HEAD <code>pre-commit</code>]
| |
| |-
| |
| |
| |
| The hook stores new objects in a local .ExternalData directory at the top of the source tree.
| |
| It also adds them to the local Git repository in a location disjoint from the project history.
| |
| |}
| |
| | |
| == Push ==
| |
| {| style="width: 100%"
| |
| |-
| |
| |width=60%|
| |
| Follow the instructions to [[ITK/Git/Develop#Share_a_Topic|share the topic]].
| |
| When you push it to Gerrit for review using
| |
| :<code>$ git gerrit-push</code>
| |
| |align="center"|
| |
| [http://itk.org/gitweb?p=ITK.git;a=blob;f=Utilities/Git/git-gerrit-push;hb=HEAD <code>git-gerrit-push</code>]
| |
| |-
| |
| |
| |
| part of the output will be of the form
| |
| :{|
| |
| |
| |
| * ...:refs/data/commits/... [new branch]
| |
| * HEAD:refs/for/master/''my-topic'' [new branch]
| |
| Pushed refs/data and removed local copy:
| |
| MD5/...
| |
| |}
| |
| This means that the git-gerrit-push script pushed the topic and uploaded the data it references.
| |
| |}
| |