Ticket #2309 (closed: fixed)

Opened 10 years ago

Last modified 5 years ago

Sort out the dependencies in the tests

Reported by: Russell Taylor Owned by: Russell Taylor
Priority: major Milestone: Release 2.0
Component: Infrastructure Keywords:
Cc: Blocked By:
Blocking: Tester: Michael Reuter

Description

I'm not happy that, at present, if I change a test in Geometry and want to recompile, everything up to DataHandling in the framework is a dependency. This is as a result of TestHelpers. I think this should be split up so that tests just link to individual files.

More generally, we should make sure no tests rely on anything in a 'higher' package, either explicitly or implicity (e.g. they rely on an algorithm, or sub-algorithm, being in the factory). Sideways dependencies are probably unavoidable but should be minimised.

Change History

comment:1 Changed 10 years ago by Russell Taylor

  • Summary changed from Sort ot the dependencies in the tests to Sort out the dependencies in the tests

comment:2 Changed 10 years ago by Nick Draper

  • Milestone changed from Iteration 27 to Iteration 28

Bulk move of tickets at the end of iteration 27

comment:3 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 28 to Iteration 29

Bulk move of tickets at the end of iteration 28

comment:4 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 29 to Iteration 30

"New" tickets moved at the code freeze of iteration 29

comment:5 Changed 9 years ago by Russell Taylor

In [14341]:

Split out SANSInstrumentCreationHelper from ComponentCreationHelper. Re #2309.

comment:6 Changed 9 years ago by Russell Taylor

In [14350]:

Move InstrumentRayTracer performance test into DataHandling because it uses LoadInstrument. Re #2309.

comment:7 Changed 9 years ago by Russell Taylor

In [14355]:

Feels like a hack, but this removes the need for GeometryTest to depend on TestHelpers. Re #2309.

comment:8 Changed 9 years ago by Russell Taylor

In [14362]:

Add static methods to prevent calling of test constructors multiple times. Re #2309.

comment:9 Changed 9 years ago by Russell Taylor

In [14365]:

Add static methods to prevent calling of test constructors multiple times. Re #2309.

comment:10 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 30 to Iteration 31

Bulk move of tickets to iteration 31 at the iteration 30 code freeze

comment:11 Changed 9 years ago by Russell Taylor

  • Status changed from new to accepted

comment:12 Changed 9 years ago by Russell Taylor

First step at eliminating TestHelpers library. Re #2309.

Involves folding the helper classes into the test executables themselves. Does mean they may be compiled multiple times, but I think the benefits outweigh the drawbacks.

Changeset: 7de4eeb15b1218a4106458090bc6102049761130

comment:13 Changed 9 years ago by Russell Taylor

Eliminate TestHelpers as a separate library. Re #2309.

Changeset: b030ed491f179519d6569ad8c6b26fe8f1e4da6b

comment:14 Changed 9 years ago by Russell Taylor

Try to fix VatesAPITest in the dark. Re #2309.

Changeset: a5c5d0e878ae9aa0970af5829baee4e13254f076

comment:15 Changed 9 years ago by Russell Taylor

Try harder. Re #2309.

Changeset: 2d327d8c6675f7b47fd166d2a59f280cc39dba6f

comment:16 Changed 9 years ago by Russell Taylor

Try even harder. Re #2309.

Changeset: 8e752e43f2b39f385cf86aab878c4f69ebcb982f

comment:17 Changed 9 years ago by Russell Taylor

Still trying... Re #2309.

Changeset: c96e9651437959f669ca1458ed35b81c2e1a9f10

comment:18 Changed 9 years ago by Russell Taylor

Windows fix. Re #2309.

Changeset: b3b3723c3f03ae36e3e0e7ca23d360f000511319

comment:19 Changed 9 years ago by Russell Taylor

Missed an include that was in a very odd place. Re #2309.

Changeset: 71ba667dc27d6eb2359fdd9615893f891cf118d9

comment:20 Changed 9 years ago by Russell Taylor

Remove WikiMaker - use wiki_maker.py instead. Re #2309.

Changeset: 78ebb91ee5f4863981affc7d44eab0e2e12c5fb7

comment:21 Changed 9 years ago by Russell Taylor

  • Status changed from accepted to verify
  • Resolution set to fixed

That'll do for now. There are still some dependencies across algorithm packages that it would be nice to lose (e.g. MDEventsTest depends on DataHandling) but the worst is gone.

For the record, he's a copy of an email I sent out to mantid-developers explaining the changes:

I’ve just made some changes to the way the test helper functions/classes (in Code/Mantid/Framework/TestHelpers) are used. Previously, the various files were compiled into a separate shared library to which any test package could link. The downside of this was that it led to any test package that made use of the TestHelpers library depending on everything that any test helper file depended on. This was annoying (to me at least) because it meant you often had to compile far more that was strictly necessary just to run a test on the class you were working on.

The new way is that individual test files are compiled into the test executable itself. No changes are required within the test files themselves (just include the header), but if a new test helper file is introduced to a test then you need to make sure it’s source file is mentioned in the relevant CMakeLists, something like this:

 if ( CXXTEST_FOUND )
   include_directories ( ../TestHelpers/inc )
   set ( TESTHELPER_SRCS ../TestHelpers/src/ComponentCreationHelper.cpp         
                         ../TestHelpers/src/WorkspaceCreationHelper.cpp )
   cxxtest_add_test ( DataObjectsTest ${TEST_FILES} )
 ....

A slight drawback is that this means that a particular test helper may be compiled multiple times (once for each package). This could be ameliorated by keeping the helper files as atomic as possible rather than adding everything to just a few files.

As a reminder, test packages should not depend on packages above the package they’re testing (see the mostly up-to-date http://www.mantidproject.org/Mantid_Package_Diagram) – e.g. GeometryTests must not depend on API. Some sideways dependencies are probably inevitable (at least implicitly), but should be minimized (and I’ll probably have a go at getting rid of some that are there at present). One way to help in this (w.r.t. DataHandling) is to remember that unit tests should not load real data/files unless they’re testing a file loading class.

comment:22 Changed 9 years ago by Michael Reuter

  • Status changed from verify to verifying
  • Tester set to Michael Reuter

comment:23 Changed 9 years ago by Michael Reuter

  • Status changed from verifying to closed

This looks fine to me.

comment:24 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 3156

Note: See TracTickets for help on using tickets.