diff --git a/lint4jsondb.py b/lint4jsondb.py index b2a5af0..a35f4f9 100644 --- a/lint4jsondb.py +++ b/lint4jsondb.py @@ -183,6 +183,12 @@ def finish(self): continue + # apply the directory to relative paths if needed + self.file = os.path.normpath(os.path.join(self.directory, self.file)) + self.invocation.includes = [ + os.path.normpath(os.path.join(self.directory, inc)) + for inc in self.invocation.includes] + class Lint4JsonCompilationDb: def __init__(self, compilation_db, include_only=set(), exclude_all=set()): @@ -317,7 +323,8 @@ def execute_with(self, arg, json_db): class ExecuteLintForAllFilesInOneInvocation: def __init__(self): - self._tmp_file = tempfile.NamedTemporaryFile(mode='w+', delete=False, suffix='.lnt') + self._tmp_file = tempfile.NamedTemporaryFile( + mode='w+', delete=False, suffix='.lnt') self._last_invocation = None def _create_temporary_lint_config(self, json_db): diff --git a/test_lint4jsondb.py b/test_lint4jsondb.py index 58b6a5a..9e70fee 100644 --- a/test_lint4jsondb.py +++ b/test_lint4jsondb.py @@ -19,7 +19,7 @@ def tearDown(self): os.remove(self._json_tested) def __create_temp_json(self, content): - with tempfile.TemporaryFile('wb', delete=False) as f: + with tempfile.NamedTemporaryFile('wb', delete=False) as f: self._json_tested = f.name f.write(content) @@ -264,7 +264,8 @@ def test_invocation(self, mock_call, mock_os_path_exists, mock_os_makedirs): 'stderr': -2, 'stdout': -1}) # ensure lint is called - self.assertEqual(args.pop(0), os.path.join("", "")) + self.assertEqual(args.pop(0), os.path.join( + "", "")) # ensure lint suppresses the banner line self.assertEqual(args.pop(0), '-b') # ensure lint's "lnt" directory was added @@ -280,3 +281,7 @@ def test_invocation(self, mock_call, mock_os_path_exists, mock_os_makedirs): self.assertEqual(args.pop(0), '-i"i2"') # ensure that the file to check is passed finally self.assertEqual(args.pop(0), "") + + +if __name__ == "__main__": + unittest.main()