Changes between Version 3 and Version 4 of DevelopmentPage/CodeTesting


Ignore:
Timestamp:
Nov 29, 2012, 4:55:37 PM (12 years ago)
Author:
Valentin Hirschi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DevelopmentPage/CodeTesting

    v3 v4  
    1616== What to do if they fail? Managing the existing IOTests ==
    1717
    18 To access the functionalities for the management of the IOTests, you must run the './tests/test_manager.py' with the '-i' option followed by either '-U' or '-R':
     18The 'tests/test_manager.py' script shall be used for managing the IOTest. Find more information on this by typing:
     19
     20'''./tests/test_manager.py help'''
     21
     22To manage the IOTests, you must run the './tests/test_manager.py' with the '-i' option followed by either '-U' or '-R'.
    1923
    2024'''./tests/test_manager.py -i -R <optional_test_specifier>'''
     
    2630    => You can add '-f' after '-i' in the command above to bypass the question and automatically update everything. You will get a list of the modification at the end and have one last chance of ignoring them.  Please use this with care, as blindly updating the reference files ruins the purpose of these tests.
    2731
    28 If <optional_test_specifier> is absent, the test_manager will span all IOTest. You can however specify it to target only certain tests or files. The syntax of the specifier is:
     32If <optional_test_specifier> is absent, the test_manager will span all IOTests. You can however specify it to target only certain tests or files. The syntax of the specifier is:
    2933
    3034'''<optional_test_specifier> == FolderNames/TestNames/FileNames'''
     
    4145  => Consider all the files referenced in all the tests placed in the folder named short_ML_SMQCD_optimized and short_ML_SMQCD_default.
    4246
    43 Notice that if a file is written out based on the content of unordered dictionaries, then this comparison is bound to fail and the file should not be referenced. You can modify what are the referenced files in the the IOTest class in 'tests/IOTests' or at the time of the IOTest creation in the different test classes inheriting from IOTestManager (See below for more information).
     47If you edit the content of the folder 'tests/input_files/IOTestsComparison' by yourself (discouraged, use the '-U' functionality instead as much as possible) and want to synchronized this folder with the revisioned 'tests/input_files/IOTestsComparison.tar.bz2' tarball, you can simply use:
    4448
     49'''./tests/test_manager.py -s '''
    4550
     51All changes you bring to the tarball via the test_manager are registered in the 'tests/input_files/IOTestsRefModifs.log' so that one can see what files were modified compared to earlier revisions of the code.
    4652
     53Finally, notice that if a file is written out based on the content of unordered dictionaries, then this comparison is bound to fail and the file should not be referenced. You can modify what are the referenced files in the the IOTest class in 'tests/IOTests' or at the time of the IOTest creation in the different test classes inheriting from IOTestManager (See below for more information).
    4754
     55== Creating new IOTests ==
     56
     57In order to do so, you simply have to create a new class in the 'unit_tests' or 'parallel_tests' directory which inherits from 'IOTests.IOTestManager' only. Then you should use the 'setUp' function to add your IOTest with the function 'self.addIOTest(folderName,testName,IOTest)' where folderName and testName are two strings identifying the test and specifying where the reference files are placed in tests/input_files/IOTestsComparison. The last argument IOTest must be an instance of the class IOTests.IOTest. This IOTest class is designed for the creation of a loop process and its output whose files are used for comparison. Of course, you are free to define your own IOTest, inheriting from IOTests.IOTest, and overloading its parameters and the function run() which specifies how the files are generated. Notice however that its attribute 'testedFiles' must be specified. It is a list of the path (relative to the path returned by the run() function) of files to be used as a reference. Notice that for each element of this list you can use regular expressions. On top of this you can prepend '-' to an explicit file name to veto it from the list of files considered (could be done with regexps, but it is simpler like this). Here is an example of how one can define the 'testedFiles'
     58
     59'''testedFiles = ['../../Source/MODEL/[.+\.(f|inc)]','-../../Source/MODEL/lha_read.f','-../../Source/MODEL/param_read.inc',]'''
     60  => Consider all files with the extension .f or .inc in the folder '../../Source/MODEL' relative to the path output by the run() function, but vetoing the files 'param_read.inc' and 'lha_read.f'. Notice that regular expressions cannot be used in conjunction with the '-' prepend syntax.
     61
     62You can find a complete example of the implementation of IOTests in the class 'IOExportMadLoopUnitTest' of the module 'tests/unit_tests/loop/test_loop_exporters.py'.
    4863
    4964= Unit tests =