def test_git_clean(self): d = common.BuildEnvironment.build_defaults() b = common.BuildEnvironment(d) # Mock the call to run_subprocess. b.run_subprocess = self.git_clean_verifier os.path.exists = MockOsPathExists(False) # reset in tearDown # first, unless enabled, git_clean() should do nothing. b.git_clean() self.assertFalse(self.git_clean_ran) self.assertFalse(self.git_reset_ran) b.enable_git_clean = True # next, should do nothing if not in git dir b.git_clean() self.assertFalse(self.git_clean_ran) self.assertFalse(self.git_reset_ran) os.path.exists = MockOsPathExists(True) # reset in tearDown # finally, should run b.project_directory = 'e' b.git_clean() self.assertTrue(self.git_clean_ran) self.assertTrue(self.git_reset_ran)
def test_run_make_clean(self): d = common.BuildEnvironment.build_defaults() b = common.BuildEnvironment(d) b.clean = True # Mock the call to run_subprocess. b.run_subprocess = MakeVerifier(self, ['-C', 'e', 'clean']) b.project_directory = 'e' b.run_make()
def test_run_make(self): d = common.BuildEnvironment.build_defaults() b = common.BuildEnvironment(d) # Mock the call to run_subprocess. b.run_subprocess = MakeVerifier(self, ['-C', 'e', 'c', 'd']) b.make_flags = 'c d' b.project_directory = 'e' b.run_make()
def test_init(self): d = common.BuildEnvironment.build_defaults() b = common.BuildEnvironment(d) self.assertEqual(b.project_directory, d[common._PROJECT_DIR]) self.assertEqual(b.cpu_count, d[common._CPU_COUNT]) self.assertEqual(b.make_path, d[common._MAKE_PATH]) self.assertEqual(b.git_path, d[common._GIT_PATH]) self.assertEqual(b.make_flags, d[common._MAKE_FLAGS]) self.assertEqual(b.enable_git_clean, d[common._GIT_CLEAN]) self.assertEqual(b.verbose, d[common._VERBOSE]) self.assertEqual(b.output_directory, d[common._OUTPUT_DIR]) self.assertEqual(b.clean, d[common._CLEAN])
def test_get_project_directory_relative(self): b = common.BuildEnvironment(common.BuildEnvironment.build_defaults()) directories = ('examples', 'libfplutil_example') b.project_directory = os.path.join(directories[0], directories[1]) expected = os.path.join(os.getcwd(), directories[0]) self.assertEquals(expected, b.get_project_directory(path='..'))
def test_get_project_directory(self): b = common.BuildEnvironment(common.BuildEnvironment.build_defaults()) b.project_directory = os.path.join('examples', 'libfplutil_example') expected = os.path.join(os.getcwd(), b.project_directory) self.assertEquals(expected, b.get_project_directory())
def test_find_binary_missing(self): build_environment = common.BuildEnvironment( common.BuildEnvironment.build_defaults()) self.assertNotEquals( None, build_environment._find_binary(common.BuildEnvironment.GIT))
def test_find_binary_found(self): build_environment = common.BuildEnvironment( common.BuildEnvironment.build_defaults()) common._find_executable = lambda name, path=None: None with self.assertRaises(common.ToolPathError): build_environment._find_binary(common.BuildEnvironment.MAKE)