Difference between revisions of "ITK/Git/Develop/Data"

From KitwarePublic
< ITK‎ | Git‎ | Develop
Jump to navigationJump to search
Line 33: Line 33:
  itk_add_test(NAME MyTest COMMAND ... --compare DATA{Baseline/''MyTest.png''} ...)
  itk_add_test(NAME MyTest COMMAND ... --compare DATA{Baseline/''MyTest.png''} ...)
[http://itk.org/gitweb?p=ITK.git;a=blob;f=CMake/ExternalData.cmake;hb=HEAD <code>ExternalData.cmake</code>]

Revision as of 15:21, 15 June 2011

This page documents how to add test data while developing ITK. See our table of contents for more information.


Our workflow for adding data integrates with our standard Git development process. Start by creating a topic. Return here when you reach the "edit files" step.

Add Data

Copy the data file into your local source tree.

$ mkdir -p Modules/.../test/Baseline
$ cp ~/MyTest.png Modules/.../test/Baseline/MyTest.png

Add Test

Edit the test CMakeLists.txt file and reference the data file in an itk_add_test call. Specify the file inside DATA{...} using a path relative to the test directory:

$ edit Modules/.../test/CMakeLists.txt
itk_add_test(NAME MyTest COMMAND ... --compare DATA{Baseline/MyTest.png} ...)


Run CMake

Run cmake on the build tree:

$ cd ../ITK-build
$ cmake .
(Or just run "make" to do a full configuration and build.)
$ cd ../ITK

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".



Continue to create the topic and edit other files as necessary. Add the content link and commit it along with the other changes:

$ git add Modules/.../test/Baseline/MyTest.png.md5
$ git add Modules/.../test/CMakeLists.txt
$ git commit

The local pre-commit 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.


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.


Follow the instructions to share the topic. When you push it to Gerrit for review using

$ git gerrit-push

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:

This means that the git-gerrit-push script pushed the topic and uploaded the data it references.