def test_bindings(name, class_name, test_case, binding, prefix): """ Compare the 'bindings' files. :param name: stub of XML filename, e.g. 'test_sedml' for file test_sedml.xml. :param class_name: the test class, e.g. 'libsedml' :param test_case: brief description of tests, e.g. 'swig dir' :param binding: the binding type, e.g. 'swig' :param prefix: used to match library files, e.g. 'combine' matches libcombine-*.* :returns: number of failed tests. """ filename = test_functions.set_up_test(name, class_name, test_case) generate_binding(filename, binding) fail = 0 if binding == 'swig': fail += compare_binding_headers('ListWrapper', binding, "") fail += compare_binding_headers('OStream', binding, "") fail += compare_binding_impl('OStream', binding, "") fail += compare_binding_interface('std_set', binding, "") fail += compare_binding_headers('lib{0}'.format(prefix), binding, "") fail += compare_binding_interface('lib{0}'.format(prefix), binding, "") fail += compare_binding_interface('ASTNodes', binding, "") elif binding == 'csharp': fail += compare_binding_impl('local', binding, "") fail += compare_binding_interface('local', binding, "") fail += compare_binding_interface('lib{0}'.format(prefix), binding, "") fail += compare_binding_file('CMakeLists.txt', binding, "") fail += compare_binding_file('compile-native-files.cmake', binding, "") fail += compare_binding_file('AssemblyInfo.cs.in', binding, "") print('') return fail
def run_constraints_test(name, class_name, test_case): filename = test_functions.set_up_test(name, class_name, test_case) generate_constraints(filename) fail = compare_ext_impl(class_name) fail += compare_ext_impl(class_name, declared=True) print('') return fail
def run_plug_test(name, class_name, test_case, num): filename = test_functions.set_up_test(name, class_name, test_case) generate_plugin_header(filename, num) fail = compare_ext_headers(class_name) fail += compare_ext_impl(class_name) print('') return fail
def run_constraints_test(name, class_name, test_case): filename = test_functions.set_up_test(name, class_name, test_case) generate_constraints(filename) fail = compare_ext_impl(class_name) fail += compare_ext_impl(class_name, declared=True) print('') return fail
def run_plug_test(name, class_name, test_case, num): filename = test_functions.set_up_test(name, class_name, test_case) generate_plugin_header(filename, num) fail = compare_ext_headers(class_name) fail += compare_ext_impl(class_name) print('') return fail
def test_global(name, class_name, test_case): filename = test_functions.set_up_test(name, class_name, test_case) generate_global(filename) fail = 0 fail += compare_code_txt('VERSION') fail += compare_code_txt('README', 'md') print('') return fail
def run_templates(name, class_name, test_case, list_of): filename = test_functions.set_up_test(name, class_name, test_case) generate_templates(filename) fail = compare_code_headers(class_name) fail += compare_code_impl(class_name) fail += compare_code_headers(list_of) fail += compare_code_impl(list_of) print('') return fail
def test_cmake(name, class_name, test_case, binding, prefix): filename = test_functions.set_up_test(name, class_name, test_case) generate_cmake(filename, binding) fail = 0 fail += compare_cmake_file('{0}'.format(prefix), prefix) fail += compare_cmake_file('src'.format(prefix), prefix) fail += compare_cmake_file('src\\bindings'.format(prefix), prefix) fail += compare_cmake_file('src\\{0}'.format(global_variables.language, prefix), prefix) print('') return fail
def run_test(name, num, class_name, test_case, list_of): filename = test_functions.set_up_test(name, class_name, test_case) generate_new_cpp_header(filename, num) fail = compare_code_headers(class_name) fail += compare_code_impl(class_name) if len(list_of) > 0: class_name = list_of fail += compare_code_headers(class_name) fail += compare_code_impl(class_name) print('') return fail
def run_valid_test(name, class_name, test_case, is_ext=True): filename = test_functions.set_up_test(name, class_name, test_case) if is_ext: generate_error_header(filename) fail = compare_ext_headers(class_name) fail += compare_ext_headers('{0}Table'.format(class_name)) else: generate_validator(filename) fail = compare_ext_headers(class_name) fail += compare_ext_impl(class_name) print('') return fail
def run_xml_fail_tests(name): """ Run an XML failure file test. :param name: XML package name, e.g. 'dyn' :return 0 on success (or file not present), 1 on failure. """ filename = test_functions.set_up_test(name, 'Examples') pkg = generate_xml_fails(filename) fail = compare_xml_fails(pkg) print('') return fail
def run_valid_test(name, class_name, test_case, is_ext=True): filename = test_functions.set_up_test(name, class_name, test_case) if is_ext: generate_error_header(filename) fail = compare_ext_headers(class_name) fail += compare_ext_headers('{0}Table'.format(class_name)) else: generate_validator(filename) fail = compare_ext_headers(class_name) fail += compare_ext_impl(class_name) print('') return fail
def run_ext_test(name, class_name, test_case, test): filename = test_functions.set_up_test(name, class_name, test_case) if test == 0: generate_extension_header(filename) elif test == 1: generate_types_header(filename) else: generate_fwd_header(filename) fail = compare_ext_headers(class_name) if test == 0: fail += compare_ext_impl(class_name) print('') return fail
def run_ext_test(name, class_name, test_case, test): filename = test_functions.set_up_test(name, class_name, test_case) if test == 0: generate_extension_header(filename) elif test == 1: generate_types_header(filename) else: generate_fwd_header(filename) fail = compare_ext_headers(class_name) if test == 0: fail += compare_ext_impl(class_name) print('') return fail
def run_forward(name, class_name, test_case): """ Run 'forward declaration' tests. :param name: stub of XML filename, e.g. 'test_sedml' for file test_sedml.xml. :param class_name: test class, e.g. 'sedmlfwd' :param test_case: brief test description, e.g. 'forward declarations' """ filename = test_functions.set_up_test(name, class_name, test_case) generate_forward(filename) fail = compare_code_headers(class_name) print('') return fail
def run_enum(name, class_name, test_case): """ Run extension types file tests. :param name: stub of XML file name, e.g. 'test_sedml' for file test_sedml.xml. :param class_name: test class, e.g. 'SedmlEnumerations' :param test_case: brief description of tests, e.g. 'enumerations'. """ filename = test_functions.set_up_test(name, class_name, test_case) generate_enum(filename) fail = compare_code_headers(class_name) fail += compare_code_impl(class_name) print('') return fail
def test_common_templates(name, class_name, test_case, prefix, lib): filename = test_functions.set_up_test(name, class_name, test_case) generate_common_templates(filename) fail = compare_code_headers('common', lib) fail += compare_code_headers('extern', lib) fail += compare_code_headers('lib{0}-config'.format(lib)) fail += compare_code_impl('lib{0}-version'.format(lib)) fail += compare_code_headers('{0}OperationReturnValues'.format(prefix)) fail += compare_code_impl('{0}OperationReturnValues'.format(prefix)) fail += compare_code_cmake('lib{0}-version.h'.format(lib)) fail += compare_code_cmake('lib{0}-config-common.h'.format(lib)) fail += compare_code_cmake('lib{0}-namespace.h'.format(lib)) print('') return fail
def run_constraints_test(name, class_name, test_case): """ Run a 'constraints' test. :param name: which set of tests this relates to, e.g. 'spatial' :param class_name: C++ class name/start of .h and .cpp file names, e.g. 'SpatialConsistencyConstraints' :param test_case: brief description, e.g. 'constraints' :return: number of failed tests """ filename = test_functions.set_up_test(name, class_name, test_case) generate_constraints(filename) fail = compare_ext_impl(class_name) fail += compare_ext_impl(class_name, declared=True) print('') return fail
def test_global(name, class_name, test_case): """ Generate and compare 'global' files, e.g. VERSION.txt, README.md. :param name: test file stub, e.g. 'test_sedml' for test_sedml.xml :param class_name: test class e.g. 'libsedml' :param test_case: brief description of test, e.g. 'global files' :returns: number of failed tests. """ filename = test_functions.set_up_test(name, class_name, test_case) generate_global(filename) fail = 0 fail += compare_code_txt('VERSION') fail += compare_code_txt('README', '.md') print('') return fail
def run_plug_test(name, class_name, test_case, num): """ Run a 'plugin' test. :param name: which set of tests this relates to, e.g. 'qual' :param class_name: C++ class name/start of .h and .cpp file names, e.g. 'QualModelPlugin' :param test_case: brief description, e.g. 'basic plugin' :param num: plugin #. It's just the index in the list of plugins that are part of large dict object form ParseXML :return: number of failed tests. """ filename = test_functions.set_up_test(name, class_name, test_case) generate_plugin_header(filename, num) fail = compare_ext_headers(class_name) fail += compare_ext_impl(class_name) print('') return fail
def run_specific_xml_fail_tests(name, start, stop, number=-1): """ Generate specific XML failure test cases??? :param name: XML file to parse :param start: :param stop: :param number: number of files to write? TODO not sure. :return: 0 on success or file mising, 1 on failure. TODO Sorry Sarah I'm a bit confused by this one as well! """ filename = test_functions.set_up_test(name, 'Examples') pkg = generate_some_xml_fails(filename, start, stop, number) fail = compare_xml_fails(pkg) print('') return fail
def run_templates(name, class_name, test_case, list_of): """ Run the 'template' file tests. :param name: name of test group e.g. 'test_sedml', 'combine-archive'. :param class_name: name of C++ class (and thus .cpp/.h filenames), e.g. 'SedBase' :param test_case: brief test description, e.g. 'templates'. :param list_of: class name (and thus filenames) of any corresponding "list of" class, e.g. 'SedListOf' :return: number of failed tests """ filename = test_functions.set_up_test(name, class_name, test_case) generate_templates(filename) fail = compare_code_headers(class_name) fail += compare_code_impl(class_name) fail += compare_code_headers(list_of) fail += compare_code_impl(list_of) print('') return fail
def test_cmake(name, class_name): # , test_case, binding): # , prefix): """ Generate and compare CMake files. TODO the following need more details: :param name: name of test, e.g. 'test_sedml' or 'combine-archive'. :param class_name: e.g. 'libsedml' or 'libcombine' :returns: number of failed tests """ filename = test_functions.set_up_test(name, class_name, "cmake") generate_cmake(filename, "cmake") fail = 0 fail += compare_cmake_file("") fail += compare_cmake_file('src') fail += compare_cmake_file('src/bindings') fail += compare_cmake_file('src/{0}'.format(gv.language)) print('') return fail
def run_test(name, num, class_name, test_case, list_of): """ Run the C++ file tests. :param name: name of test group e.g. 'test_sedml', 'combine-archive'. :param num: list index, so we only generate a particular class not all of them :param class_name: name of C++ class (and thus .cpp/.h filenames), e.g. 'CaContent' :param test_case: brief test description :param list_of: class name (and thus filenames) of any corresponding "list of" class, e.g. 'CaListOfContents' :return: number of failed tests """ filename = test_functions.set_up_test(name, class_name, test_case) generate_new_cpp_header(filename, num) fail = compare_code_headers(class_name) fail += compare_code_impl(class_name) if len(list_of) > 0: class_name = list_of fail += compare_code_headers(class_name) fail += compare_code_impl(class_name) print('') return fail
def test_bindings(name, class_name, test_case, binding, prefix): filename = test_functions.set_up_test(name, class_name, test_case) generate_binding(filename, binding) fail = 0 if binding == 'swig': fail += compare_binding_headers('ListWrapper', binding, prefix) fail += compare_binding_headers('OStream', binding, prefix) fail += compare_binding_impl('OStream', binding, prefix) fail += compare_binding_interface('std_set', binding, prefix) fail += compare_binding_headers('lib{0}'.format(prefix), binding, prefix) fail += compare_binding_interface('lib{0}'.format(prefix), binding, prefix) fail += compare_binding_interface('ASTNodes', binding, prefix) elif binding == 'csharp': fail += compare_binding_impl('local', binding, prefix) fail += compare_binding_interface('local', binding, prefix) fail += compare_binding_interface('lib{0}'.format(prefix), binding, prefix) fail += compare_binding_file('CMakeLists.txt', binding, prefix) fail += compare_binding_file('compile-native-files.cmake', binding, prefix) fail += compare_binding_file('AssemblyInfo.cs.in', binding, prefix) print('') return fail
def run_test(name, num, class_name, test_case, list_of): """ Most commonly-used test function. :param name: which set of tests this relates to. e.g. 'test_att' :param num: index??? TODO please Sarah. :param class_name: C++ class name/start of .h and .cpp file names. :param test_case: brief description, e.g. 'all types attributes required' :param list_of: e.g. 'ListOfFunctionTerms'. Can be ''. :return: number of test failures. """ filename = test_functions.set_up_test(name, class_name, test_case) generate_new_cpp_header(filename, num) fail = compare_code_headers(class_name) fail += compare_code_impl(class_name) if len(list_of) > 0: class_name = list_of fail += compare_code_headers(class_name) fail += compare_code_impl(class_name) print('') return fail
def run_ext_test(name, class_name, test_case, test): """ Run an 'extension' test. :param name: which set of tests this relates to, e.g. 'qual' :param class_name: C++ class name/start of .h and .cpp file names, e.g. 'QualExtension'. :param test_case: brief description, e.g. 'basic extension file' :param test: integer specifying which type of header file to generate. :return: number of failed tests """ filename = test_functions.set_up_test(name, class_name, test_case) if test == 0: generate_extension_header(filename) elif test == 1: generate_types_header(filename) else: generate_fwd_header(filename) fail = compare_ext_headers(class_name) if test == 0: fail += compare_ext_impl(class_name) print('') return fail
def run_valid_test(name, class_name, test_case, generate_error_files=True): """ Run a 'validation' test. :param name: which set of tests this relates to, e.g. 'test_att' :param class_name: C++ class name/start of .h and .cpp file names, e.g. 'TestSBMLError' or SBMLValidator.h :param test_case: brief description, e.g. 'error enumeration' :param generate_error_files: determines which file to generate, Error.h and ErrorTable.h if True, otherwise Validator files :return: number of failed tests. """ filename = test_functions.set_up_test(name, class_name, test_case) if generate_error_files: generate_error_header(filename) fail = compare_ext_headers(class_name) fail += compare_ext_headers('{0}Table'.format(class_name)) else: generate_validator(filename) fail = compare_ext_headers(class_name) fail += compare_ext_impl(class_name) print('') return fail
def test_common_templates(name, class_name, test_case, prefix, lib): """ Compare 'common' template files. :param name: e.g. 'test_sedml' :param class_name: C++ class/filenames, e.g. 'SedBase' :param test_case: e.g. 'common' :param prefix: e.g. 'Sed' :param lib: used for comparing lib files, e.g. 'sedml' for 'libsedml-*'. :return: number of failed tests. """ filename = test_functions.set_up_test(name, class_name, test_case) generate_common_templates(filename) fail = compare_code_headers('common') fail += compare_code_headers('extern') fail += compare_code_headers('lib{0}-config'.format(lib)) fail += compare_code_impl('lib{0}-version'.format(lib)) fail += compare_code_headers('{0}OperationReturnValues'.format(prefix)) fail += compare_code_impl('{0}OperationReturnValues'.format(prefix)) fail += compare_code_cmake('lib{0}-version.h'.format(lib)) fail += compare_code_cmake('lib{0}-config-common.h'.format(lib)) fail += compare_code_cmake('lib{0}-namespace.h'.format(lib)) print('') return fail
def run_forward(name, class_name, test_case): filename = test_functions.set_up_test(name, class_name, test_case) generate_forward(filename) fail = compare_code_headers(class_name) print('') return fail
def run_specific_xml_fail_tests(name, start, stop, number=-1): filename = test_functions.set_up_test(name, 'Examples') pkg = generate_some_xml_fails(filename, start, stop, number) fail = compare_xml_fails(pkg) print('') return fail
def run_xml_fail_tests(name): filename = test_functions.set_up_test(name, 'Examples') pkg = generate_xml_fails(filename) fail = compare_xml_fails(pkg) print('') return fail
def run_xml_fail_tests(name): filename = test_functions.set_up_test(name, 'Examples') pkg = generate_xml_fails(filename) fail = compare_xml_fails(pkg) print('') return fail