def test(self, cookie, path, extra): path_check = path.replace('.pl', '_check.pl') with open(path, 'r') as f: code = f.read() with open(path_check, 'w') as f: f.write( 'use lib "/tmp/tester/perl/source/lib"; use strict; use warnings; CHECK { sub __check__ { ' + code + '\n\n}}\n\n__check__;\n') args = ['perl', '-cWT', path_check] retcode, output = common.check_output_and_error(args) output = output.strip('\r\n') # FIXME: filter out some internal Perl problems with the Math::Complex module filtered_output = [ line for line in output.split('\n') if not line.startswith('Prototype mismatch: sub Math::Complex::') ] success = retcode == 0 and len( filtered_output) == 1 and 'syntax OK' in output self.handle_result(cookie, output, success)
def test(self, cookie, path, extra): args = ['/usr/bin/ruby', '-wc', path] retcode, output = common.check_output_and_error(args) output = output.strip('\r\n') success = retcode == 0 and len( output.split('\n')) == 1 and 'Syntax OK' in output self.handle_result(cookie, output, success)
def test(self, cookie, path, extra): if extra: shutil.copy(path, '/tmp/tester/delphi') path = os.path.join('/tmp/tester/delphi', os.path.split(path)[1]) args = ['fpc', '-vw', '-Fu/tmp/tester/delphi/source', '-l', path] retcode, output = common.check_output_and_error(args) output = output.strip('\r\n') success = retcode == 0 and 'warning(s) issued' not in output self.handle_result(cookie, output, success)
def test(self, cookie, path, extra): path_check = path.replace('.sh', '-check.sh') with open(path, 'r') as f: code = f.read() with open(path_check, 'w') as f: f.write(code.replace('; read dummy', '').replace('kill -- -$$', 'kill $(jobs -p)')) os.chmod(path_check, 0o755) args = [path_check] env = {'TINKERFORGE_SHELL_BINDINGS_DRY_RUN': '1', 'PATH': '/tmp/tester/shell:{0}'.format(os.environ['PATH'])} retcode, output = common.check_output_and_error(args, env=env) success = retcode == 0 and output.strip() in ['', 'Press key to exit'] self.handle_result(cookie, output, success)
def test(self, cookie, path, extra): path_check = path.replace('.sh', '-check.sh') with open(path, 'r') as f: code = f.read() with open(path_check, 'w') as f: f.write( code.replace('; read dummy', '').replace('kill -- -$$', 'kill $(jobs -p)')) os.chmod(path_check, 0o755) args = [path_check] env = { 'TINKERFORGE_SHELL_BINDINGS_DRY_RUN': '1', 'PATH': '/tmp/tester/shell:{0}'.format(os.environ['PATH']) } retcode, output = common.check_output_and_error(args, env=env) success = retcode == 0 and output.strip() in ['', 'Press key to exit'] self.handle_result(cookie, output, success)
def test(self, cookie, path, extra): path_lint = path.replace('.pl', '_lint.pl') with open(path, 'r') as f: code = f.read() with open(path_lint, 'w') as f: f.write('use lib "/tmp/tester/perl/source/lib";' + code) args = ['perl', '-MO=Lint,all', path_lint] retcode, output = common.check_output_and_error(args) output = output.strip('\r\n') if retcode != 0 and output == "Can't locate object method \"NAME\" via package \"B::IV\" at /usr/share/perl5/B/Lint.pm line 575.\nCHECK failed--call queue aborted.": # FIXME: ignore the Lint module having bugs success = True else: # FIXME: ignore the Lint module being confused about constants filtered_output = [] for line in output.split('\n'): if not line.startswith("Bare sub name 'HOST' interpreted as string at") and \ not line.startswith("Bare sub name 'PORT' interpreted as string at") and \ not line.startswith("Bare sub name 'UID' interpreted as string at") and \ not line.startswith("Bare sub name 'SECRET' interpreted as string at") and \ not line.startswith("Bare sub name 'NUM_LEDS' interpreted as string at") and \ not line.startswith("Bare sub name 'NDEF_URI' interpreted as string at") and \ not line.startswith("Bare sub name 'WIDTH' interpreted as string at") and \ not line.startswith("Bare sub name 'HEIGHT' interpreted as string at"): filtered_output.append(line) success = retcode == 0 and len(filtered_output) == 1 and 'syntax OK' in output self.handle_result(cookie, output, success)
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^Example.*\.js'): shutil.copy(example[1], self.tmp_nodejs_examples_dir) for example in common.find_examples(root_dir, r'^Example.*\.html'): shutil.copy(example[1], self.tmp_browser_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): if filename == 'TinkerforgeNPM.js': shutil.copy(os.path.join(self.get_bindings_dir(), filename), os.path.join(self.tmp_nodejs_package_dir, 'Tinkerforge.js')) elif filename == 'BrowserAPI.js': shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_nodejs_source_tinkerforge_dir) elif filename == 'TinkerforgeSource.js': shutil.copy(os.path.join(self.get_bindings_dir(), filename), os.path.join(self.tmp_nodejs_source_dir, 'Tinkerforge.js')) else: shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_nodejs_package_lib_dir) # Make package.json version = self.get_changelog_version() common.specialize_template(os.path.join(root_dir, 'package.json.template'), os.path.join(self.tmp_nodejs_package_dir, 'package.json'), {'<<VERSION>>': '.'.join(version)}) shutil.copy(os.path.join(root_dir, 'IPConnection.js'), self.tmp_nodejs_package_lib_dir) shutil.copy(os.path.join(root_dir, 'Device.js'), self.tmp_nodejs_package_lib_dir) shutil.copy(os.path.join(root_dir, 'LICENSE'), self.tmp_nodejs_package_dir) shutil.copy(os.path.join(root_dir, 'README.md'), self.tmp_nodejs_package_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.js'), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Device.js'), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'changelog.txt'), self.tmp_dir) shutil.copy(os.path.join(root_dir, 'readme.txt'), self.tmp_dir) shutil.copy(os.path.join(root_dir, '..', 'configs', 'license.txt'), self.tmp_dir) # Copy browser specific files shutil.copy(os.path.join(root_dir, 'es5-shim.js'), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'es5-sham.js'), self.tmp_nodejs_source_tinkerforge_dir) # Make Tinkerforge.js for browser with browserify retcode, output = common.check_output_and_error(['browserify', '--version']) if retcode != 0: raise common.GeneratorError('Could not get browserify version') if tuple([int(n) for n in output.strip('\r\n').split('.')]) < (13, 1, 1): raise common.GeneratorError('Need browserify version >= 13.1.1') with common.ChangedDirectory(self.tmp_nodejs_source_tinkerforge_dir): args = ['browserify'] args.extend(sorted(os.listdir(self.tmp_nodejs_source_tinkerforge_dir))) args.append('-o') args.append(os.path.join(self.tmp_browser_source_dir, 'Tinkerforge.js')) common.execute(args) # Remove browser specific files os.remove(os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'BrowserAPI.js')) os.remove(os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'es5-shim.js')) os.remove(os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'es5-sham.js')) # Generate the NPM package and put it on the root of ZIP archive with common.ChangedDirectory(self.tmp_nodejs_package_dir): common.execute(['npm', 'pack']) package_name = 'tinkerforge-{0}.{1}.{2}.tgz'.format(*version) shutil.copy(os.path.join(self.tmp_nodejs_package_dir, package_name), os.path.join(self.tmp_nodejs_dir, 'tinkerforge.tgz')) shutil.copy(os.path.join(self.tmp_nodejs_package_dir, package_name), os.path.join(root_dir, package_name)) # Remove package directory shutil.rmtree(self.tmp_nodejs_package_dir) # Make zip self.create_zip_file(self.tmp_dir) # copy Tinkerforge.js to bindings root dir so copy_all.py can pick it up shutil.copy(os.path.join(self.tmp_browser_source_dir, 'Tinkerforge.js'), root_dir)
def test(self, cookie, path, extra): # skip OLED scribble example because mingw32 has no libgd package if self.compiler.startswith('mingw32-') and path.endswith('example_scribble.c'): self.handle_result(cookie, '>>> skipping', True) return if extra: shutil.copy(path, '/tmp/tester/c') path = os.path.join('/tmp/tester/c', os.path.split(path)[1]) output = path[:-2] if not extra and '/brick' in path: dirname = os.path.split(path)[0] device = '/tmp/tester/c/source/{0}_{1}.c'.format(os.path.split(os.path.split(dirname)[0])[-1], os.path.split(dirname)[-1]) else: device = '' args = [] if self.compiler == 'gcc': args += ['gcc', '-std=c99', '-pthread'] elif self.compiler == 'g++': args += ['g++', '-std=c++98', '-pthread'] elif self.compiler == 'mingw32-gcc': args += ['x86_64-w64-mingw32-gcc', '-Wno-error=return-type'] elif self.compiler == 'mingw32-g++': args += ['x86_64-w64-mingw32-g++', '-Wno-error=return-type'] elif self.compiler == 'scan-build clang': args += ['scan-build', 'clang', '-std=c99', '-pthread'] else: raise common.GeneratorError('Invalid compiler ' + self.compiler) args += ['-Wall', '-Wextra', '-Werror', '-O2', '-I/tmp/tester/c/source', '-o', output, '/tmp/tester/c/source/ip_connection.c'] if len(device) > 0: args.append(device) elif extra: dependencies = glob.glob('/tmp/tester/c/source/*.c') dependencies.remove('/tmp/tester/c/source/ip_connection.c') args.append('-Wno-error=unused-parameter') args += dependencies args.append(path) if self.compiler.startswith('mingw32-'): args += ['-lws2_32'] if path.endswith('example_scribble.c'): args += ['-lm', '-lgd'] retcode, output = common.check_output_and_error(args) success = retcode == 0 if self.compiler == 'scan-build clang' and success and 'scan-build: No bugs found.\n' not in output: success = False self.handle_result(cookie, output, success)