[analyzer][test] create separate c/c++ files for the tests
clang/clang++ is more strict to use the right compiler
for the right files (gives an error, gcc/g++ gives just
a warning).
In OSX environment gcc/g++ is a symlink to clang/clang++
which gives errors running these tests.
@@ -105,16 +105,17 @@ class TestAnalyze(unittest.TestCase):
# GIVEN
build_json = os.path.join(self.test_workspace, "build_simple.json")
reports_dir = self.report_dir
- source_file = os.path.join(self.test_workspace, "simple.cpp")
+ source_file_cpp = os.path.join(self.test_workspace, "simple.cpp")
+ source_file_c = os.path.join(self.test_workspace, "simple.c")
# Create a compilation database.
build_log = [{"directory": self.test_workspace,
- "command": "g++ -c " + source_file,
- "file": source_file
+ "command": "gcc -c " + source_file_c,
+ "file": source_file_c
},
{"directory": self.test_workspace,
- "command": "clang++ -c " + source_file,
- "file": source_file
+ "command": "clang++ -c " + source_file_cpp,
+ "file": source_file_cpp
}
]
@@ -125,7 +126,10 @@ class TestAnalyze(unittest.TestCase):
simple_file_content = "int main() { return 0; }"
# Write content to the test file
- with open(source_file, 'w') as source:
+ with open(source_file_cpp, 'w') as source:
+ source.write(simple_file_content)
+
+ with open(source_file_c, 'w') as source:
source.write(simple_file_content)
# Create analyze command.
