Gtest now works, though still a bit hackish.

pull/15/head
Jussi Pakkanen 12 years ago
parent 1b11431079
commit 7882acbd72
  1. 18
      backends.py
  2. 3
      dependencies.py
  3. 6
      test cases/frameworks/2 gtest/meson.build
  4. 9
      test cases/frameworks/2 gtest/test.cc

@ -512,12 +512,16 @@ class NinjaBackend(Backend):
commands = self.generate_basic_compiler_flags(target, compiler) commands = self.generate_basic_compiler_flags(target, compiler)
commands.append(compiler.get_include_arg(self.get_target_private_dir(target))) commands.append(compiler.get_include_arg(self.get_target_private_dir(target)))
if is_generated: if is_generated:
abs_src = os.path.join(self.get_target_private_dir(target), src) rel_src = os.path.join(self.get_target_private_dir(target), src)
else: else:
abs_src = os.path.join(self.build_to_src, target.get_source_subdir(), src) rel_src = os.path.join(self.build_to_src, target.get_source_subdir(), src)
abs_obj = os.path.join(self.get_target_private_dir(target), src) if os.path.isabs(src):
abs_obj += '.' + self.environment.get_object_suffix() src_filename = os.path.basename(src)
dep_file = abs_obj + '.' + compiler.get_depfile_suffix() else:
src_filename = src
rel_obj = os.path.join(self.get_target_private_dir(target), src_filename)
rel_obj += '.' + self.environment.get_object_suffix()
dep_file = rel_obj + '.' + compiler.get_depfile_suffix()
pchlist = target.get_pch() pchlist = target.get_pch()
if len(pchlist) == 0: if len(pchlist) == 0:
pch_dep = [] pch_dep = []
@ -540,14 +544,14 @@ class NinjaBackend(Backend):
commands += self.get_pch_include_args(compiler, target) commands += self.get_pch_include_args(compiler, target)
compiler_name = '%s_COMPILER' % compiler.get_language() compiler_name = '%s_COMPILER' % compiler.get_language()
element = NinjaBuildElement(abs_obj, compiler_name, abs_src) element = NinjaBuildElement(rel_obj, compiler_name, rel_src)
if len(header_deps) > 0: if len(header_deps) > 0:
element.add_dep([os.path.join(self.get_target_private_dir(target), d) for d in header_deps]) element.add_dep([os.path.join(self.get_target_private_dir(target), d) for d in header_deps])
element.add_orderdep(pch_dep) element.add_orderdep(pch_dep)
element.add_item('DEPFILE', dep_file) element.add_item('DEPFILE', dep_file)
element.add_item('FLAGS', commands) element.add_item('FLAGS', commands)
element.write(outfile) element.write(outfile)
return abs_obj return rel_obj
def generate_pch(self, target, outfile): def generate_pch(self, target, outfile):
for pch in target.get_pch(): for pch in target.get_pch():

@ -113,10 +113,9 @@ class GTestDependency():
def get_compile_flags(self): def get_compile_flags(self):
return ['-I' + self.include_dir, '-I' + self.src_include_dir] return ['-I' + self.include_dir, '-I' + self.src_include_dir]
def get_link_flags(self): def get_link_flags(self):
return [] return ['-lpthread']
def get_version(self): def get_version(self):
return '1.something_maybe' return '1.something_maybe'
def get_sources(self): def get_sources(self):
return [self.all_src, self.main_src] return [self.all_src, self.main_src]

@ -0,0 +1,6 @@
project('gtest', 'cxx')
gtest = find_dep('gtest', required : true)
e = executable('testprog', 'test.cc', deps : gtest)
add_test('gtest test', e)

@ -0,0 +1,9 @@
#include<gtest/gtest.h>
TEST(basic_test, eq_works) {
ASSERT_EQ(0, 1-1) << "Equality is broken. Mass panic!";
}
TEST(basic_test, neq_works) {
ASSERT_NE(15, 106) << "Inequal is equal. The foundations of space and time are in jeopardy.";
}
Loading…
Cancel
Save