def _copy_files(self, target_dir): """Copy test harness and file-under-test.""" builder = Builder(action=recursive_template_action, emitter=recursive_template_emitter) _inc_dirs, _sources, headers = unit_test.find_sources('firmware/src') # Render the template env = Environment(tools=[], BUILDERS={'render': builder}) env['RECURSIVE_TEMPLATE'] = self.UNIT_TEMPLATE template_files = env.render([os.path.join(target_dir, '.timestamp')], []) test_files = [] for infile in self.files: test_file = env.Command( [os.path.join(target_dir, os.path.basename(infile))], [infile], action=Copy("$TARGET", "$SOURCE")) test_files.append(test_file) # Copy all headers into the unit test for _basename, infile in viewitems(headers): test_file = env.Command( [os.path.join(target_dir, os.path.basename(infile))], [infile], action=Copy("$TARGET", "$SOURCE")) test_files.append(test_file) all_files = template_files + test_files c_files = [str(x) for x in all_files if str(x).endswith('.c')] return c_files, all_files
def _parse_module(self, mod): _inc_dirs, sources, _headers = unit_test.find_sources('firmware/src') if mod.endswith('.c'): mod = mod[:-2] if mod not in sources: raise BuildError("Could not find module specified: %s" % mod) self.files.append(sources[mod])
def _find_in_dir(self, modname, srcdir=None): if srcdir is None: testdir = os.path.dirname(self.files[0]) srcdir = os.path.abspath(os.path.join(testdir, '..', 'src')) incdirs, sources, headers = find_sources(srcdir) normsrc = os.path.normpath(srcdir) if normsrc not in self.processed_dirs: self.includes += incdirs self.processed_dirs.add(normsrc) if modname not in sources: return False self.files.append(sources[modname]) return True