def setUp(self): uth.reset() cap = configargparse.getArgumentParser( description='Configargparser in test code', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=False)
def setUp(self): uth.reset() cap = configargparse.getArgumentParser( description="Configargparser in test code", formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c", "--config"], ignore_unknown_config_file_keys=False, )
def test_build_and_link_static_library(self): # Setup origdir = os.getcwd() self._tmpdir = tempfile.mkdtemp() # Mimic the build.sh and create the library in a 'mylib' subdirectory # Copy the sample source files into the test build location mylibdir = os.path.join(self._tmpdir, "mylib") shutil.copytree(os.path.join(uth.samplesdir(), "library/mylib"), mylibdir) # Build the library temp_config_name = uth.create_temp_config(self._tmpdir) uth.create_temp_ct_conf(self._tmpdir, defaultvariant=temp_config_name[:-5]) argv = [ "--exemarkers=main", "--testmarkers=unittest.hpp", "--config=" + temp_config_name, "--CTCACHE=None", "--static", os.path.join(self._tmpdir, "mylib/get_numbers.cpp"), ] os.chdir(mylibdir) uth.reset() ct.cake.main(argv) # Copy the main that will link to the library into the test build location relativepaths = ["library/main.cpp"] realpaths = [ os.path.join(uth.samplesdir(), filename) for filename in relativepaths ] for ff in realpaths: shutil.copy2(ff, self._tmpdir) # Build the exe, linking agains the library argv = ["--config=" + temp_config_name, "--CTCACHE=None"] + realpaths os.chdir(self._tmpdir) uth.reset() ct.cake.main(argv) # Check that an executable got built for each cpp actual_exes = set() for root, dirs, files in os.walk(self._tmpdir): for ff in files: if ct.utils.isexecutable(os.path.join(root, ff)): actual_exes.add(ff) expected_exes = { os.path.splitext(os.path.split(filename)[1])[0] for filename in relativepaths } self.assertSetEqual(expected_exes, actual_exes) # Cleanup os.chdir(origdir) shutil.rmtree(self._tmpdir, ignore_errors=True)
def setUp(self): uth.reset() global _moduletmpdir if not _moduletmpdir or not os.path.exists(_moduletmpdir) : _moduletmpdir = tempfile.mkdtemp() cap = configargparse.getArgumentParser( description='Configargparser in test code', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=False)
def test_build_and_link_static_library(self): # Setup origdir = os.getcwd() self._tmpdir = tempfile.mkdtemp() # Mimic the build.sh and create the library in a 'mylib' subdirectory # Copy the sample source files into the test build location mylibdir = os.path.join(self._tmpdir,'mylib') shutil.copytree( os.path.join(uth.samplesdir(), 'library/mylib') , mylibdir) # Build the library temp_config_name = uth.create_temp_config(self._tmpdir) uth.create_temp_ct_conf(self._tmpdir,defaultvariant=temp_config_name[:-5]) argv = [ '--exemarkers=main' , '--testmarkers=unittest.hpp' , '--config='+temp_config_name , '--CTCACHE=None' , '--static' , os.path.join(self._tmpdir,'mylib/get_numbers.cpp') ] os.chdir(mylibdir) uth.reset() ct.cake.main(argv) # Copy the main that will link to the library into the test build location relativepaths = ['library/main.cpp'] realpaths = [os.path.join(uth.samplesdir(), filename) for filename in relativepaths] for ff in realpaths: shutil.copy2(ff, self._tmpdir) # Build the exe, linking agains the library argv = ['--config='+temp_config_name,'--CTCACHE=None'] + realpaths os.chdir(self._tmpdir) uth.reset() ct.cake.main(argv) # Check that an executable got built for each cpp actual_exes = set() for root, dirs, files in os.walk(self._tmpdir): for ff in files: if ct.utils.isexecutable(os.path.join(root, ff)): actual_exes.add(ff) expected_exes = { os.path.splitext( os.path.split(filename)[1])[0] for filename in relativepaths} self.assertSetEqual(expected_exes, actual_exes) # Cleanup os.chdir(origdir) shutil.rmtree(self._tmpdir, ignore_errors=True)
def setUp(self): uth.reset() global _moduletmpdir if not _moduletmpdir or not os.path.exists(_moduletmpdir): _moduletmpdir = tempfile.mkdtemp() cap = configargparse.getArgumentParser( description="Configargparser in test code", formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c", "--config"], ignore_unknown_config_file_keys=False, )
def test_cppdeps(self): tempdir = tempfile.mkdtemp() _reload_ct(tempdir) uth.reset() ct.cppdeps.main([os.path.join(uth.samplesdir(),'numbers/test_direct_include.cpp')]) output = sys.stdout.getvalue().strip().split() expected_output = [ os.path.join(uth.samplesdir(),"numbers/get_double.hpp"), os.path.join(uth.samplesdir(),"numbers/get_int.hpp"), os.path.join(uth.samplesdir(),"numbers/get_numbers.hpp")] self.assertEquals(expected_output.sort(), output.sort()) shutil.rmtree(tempdir)
def setUp(self): try: if self._tmpdir is not None: shutil.rmtree(self._tmpdir, ignore_errors=True) except AttributeError: pass self._tmpdir = tempfile.mkdtemp() uth.reset() cap = configargparse.getArgumentParser( description='Configargparser in test code', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=False)
def setUp(self): try: if self._tmpdir is not None: shutil.rmtree(self._tmpdir, ignore_errors=True) except AttributeError: pass self._tmpdir = tempfile.mkdtemp() uth.reset() cap = configargparse.getArgumentParser( description="Configargparser in test code", formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c", "--config"], ignore_unknown_config_file_keys=False, )
def test_cppdeps(self): tempdir = tempfile.mkdtemp() _reload_ct(tempdir) uth.reset() ct.cppdeps.main( [os.path.join(uth.samplesdir(), "numbers/test_direct_include.cpp")] ) output = sys.stdout.getvalue().strip().split() expected_output = [ os.path.join(uth.samplesdir(), "numbers/get_double.hpp"), os.path.join(uth.samplesdir(), "numbers/get_int.hpp"), os.path.join(uth.samplesdir(), "numbers/get_numbers.hpp"), ] self.assertEquals(expected_output.sort(), output.sort()) shutil.rmtree(tempdir)
def test_moving_headers(self): # The concept of this test is to check that ct-cake copes with header files being changed directory # Setup origdir = os.getcwd() os.mkdir(os.path.join(self._tmpdir, "subdir")) # Copy the movingheaders test files to the temp directory and compile using cake relativepaths = [ "movingheaders/main.cpp", "movingheaders/someheader.hpp" ] realpaths = [ os.path.join(uth.samplesdir(), filename) for filename in relativepaths ] for ff in realpaths: shutil.copy2(ff, self._tmpdir) os.chdir(self._tmpdir) temp_config_name = ct.unittesthelper.create_temp_config(self._tmpdir) argv = [ "--exemarkers=main", "--testmarkers=unittest.hpp", "--CTCACHE=" + os.path.join(self._tmpdir, "ctcache"), "--quiet", "--auto", "--include=subdir", "--config=" + temp_config_name, ] uth.reset() ct.cake.main(argv) self._verify_one_exe_per_main(relativepaths) # Now move the header file to "subdir" since it is already included in the path, all should be well os.rename( os.path.join(self._tmpdir, "someheader.hpp"), os.path.join(self._tmpdir, "subdir/someheader.hpp"), ) shutil.rmtree(os.path.join(self._tmpdir, "bin"), ignore_errors=True) uth.reset() ct.cake.main(argv) self._verify_one_exe_per_main(relativepaths) # Cleanup os.chdir(origdir) shutil.rmtree(self._tmpdir, ignore_errors=True)
def test_moving_headers(self): # The concept of this test is to check that ct-cake copes with header files being changed directory # Setup origdir = os.getcwd() os.mkdir(os.path.join(self._tmpdir,'subdir')) # Copy the movingheaders test files to the temp directory and compile using cake relativepaths = ['movingheaders/main.cpp', 'movingheaders/someheader.hpp'] realpaths = [os.path.join(uth.samplesdir(), filename) for filename in relativepaths] for ff in realpaths: shutil.copy2(ff, self._tmpdir) os.chdir(self._tmpdir) temp_config_name = ct.unittesthelper.create_temp_config(self._tmpdir) argv = ['--exemarkers=main' ,'--testmarkers=unittest.hpp' , '--CTCACHE='+os.path.join(self._tmpdir,'ctcache') , '--quiet' , '--auto' ,'--include=subdir' ,'--config='+temp_config_name ] uth.reset() ct.cake.main(argv) self._verify_one_exe_per_main(relativepaths) # Now move the header file to "subdir" since it is already included in the path, all should be well os.rename(os.path.join(self._tmpdir, 'someheader.hpp'), os.path.join(self._tmpdir, 'subdir/someheader.hpp')); shutil.rmtree(os.path.join(self._tmpdir, 'bin'), ignore_errors=True); uth.reset() ct.cake.main(argv) self._verify_one_exe_per_main(relativepaths) # Cleanup os.chdir(origdir) shutil.rmtree(self._tmpdir, ignore_errors=True)
def test_magicinclude(self): # This test is to ensure that the //#INCLUDE magic flag # works to pick up subdir/important.hpp # and that the --include=subdir2 subdir3 # works to pick up subdir2/important2.hpp and subdir3/important3.hpp origdir = os.getcwd() # Copy the magicinclude test files to the temp directory and compile # using cake tmpmagicinclude = os.path.join(self._tmpdir, "magicinclude") shutil.copytree(os.path.join(uth.samplesdir(), "magicinclude"), tmpmagicinclude) os.chdir(tmpmagicinclude) temp_config_name = ct.unittesthelper.create_temp_config( tmpmagicinclude) argv = [ "--exemarkers=main", "--testmarkers=unittest.hpp", "--CTCACHE=None", "--quiet", "--include=subdir2", "--include=subdir3", "--auto", "--config=" + temp_config_name, ] uth.reset() ct.cake.main(argv) relativepaths = ["magicinclude/main.cpp"] self._verify_one_exe_per_main(relativepaths) # Cleanup os.chdir(origdir) shutil.rmtree(self._tmpdir, ignore_errors=True)
def test_magicinclude(self): # This test is to ensure that the //#INCLUDE magic flag # works to pick up subdir/important.hpp # and that the --include=subdir2 subdir3 # works to pick up subdir2/important2.hpp and subdir3/important3.hpp origdir = os.getcwd() # Copy the magicinclude test files to the temp directory and compile # using cake tmpmagicinclude = os.path.join(self._tmpdir, 'magicinclude') shutil.copytree( os.path.join(uth.samplesdir(), 'magicinclude') , tmpmagicinclude) os.chdir(tmpmagicinclude) temp_config_name = ct.unittesthelper.create_temp_config(tmpmagicinclude) argv = [ '--exemarkers=main', '--testmarkers=unittest.hpp', '--CTCACHE=None', '--quiet', '--include=subdir2', 'subdir3', '--auto', '--config=' + temp_config_name] uth.reset() ct.cake.main(argv) relativepaths = ['magicinclude/main.cpp'] self._verify_one_exe_per_main(relativepaths) # Cleanup os.chdir(origdir) shutil.rmtree(self._tmpdir, ignore_errors=True)
def _call_ct_cake(self, extraargv=[], cache_home="None"): assert cache_home is not None # Note object None is not string 'None' uth.reset() ct.cake.main(self._create_argv(cache_home) + extraargv)
def tearDown(self): shutil.rmtree(_moduletmpdir, ignore_errors=True) uth.reset()
def tearDown(self): uth.reset()
def setUp(self): uth.reset() self._tmpdir = None
def _call_ct_cake(self, extraargv=[], cache_home='None'): assert(cache_home is not None) # Note object None is not string 'None' uth.reset() ct.cake.main(self._create_argv(cache_home) + extraargv)
def tearDown(self): uth.reset() if self._tmpdir and os.path.exists(self._tmpdir): shutil.rmtree(self._tmpdir, ignore_errors=True)
def setUp(self): uth.reset()