def _under_coverage_cmd(self, cmd): """ If self.run_under_coverage is True, it returns the arg 'cmd' altered to be run under coverage. It returns the command unaltered otherwise. """ if self.run_under_coverage: if self.xdist_ip_addresses: for module in Env.covered_modules(): cmd.append('--cov') cmd.append(module) else: cmd.append('--cov') cmd.append('--cov-report=') return cmd
def _expected_command(self, root, test_id, pytestSubclass, run_under_coverage=True, processes=0, xdist_ip_addresses=None): """ Returns the command that is expected to be run for the given test spec and store. """ report_dir = Env.REPORT_DIR / root shard = os.environ.get('SHARD') if shard: report_dir = report_dir / 'shard_' + shard expected_statement = [ "python", "-Wd", "-m", "pytest" ] if pytestSubclass == "SystemTestSuite": expected_statement.append("--ds={}".format('{}.envs.{}'.format(root, Env.TEST_SETTINGS))) expected_statement.append("--junitxml={}".format(report_dir / "nosetests.xml")) if xdist_ip_addresses: expected_statement.append('--dist=loadscope') for ip in xdist_ip_addresses.split(','): if processes <= 0: processes = 1 if pytestSubclass == "SystemTestSuite": django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format(root) elif pytestSubclass == "LibTestSuite": if 'pavelib/paver_tests' in test_id: django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format(root) else: django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'" xdist_string = '--tx {}*ssh="ubuntu@{} -o StrictHostKeyChecking=no"' \ '//python="source /edx/app/edxapp/edxapp_env; {}; python"' \ '//chdir="/edx/app/edxapp/edx-platform"' \ .format(processes, ip, django_env_var_cmd) expected_statement.append(xdist_string) for rsync_dir in Env.rsync_dirs(): expected_statement.append('--rsyncdir {}'.format(rsync_dir)) else: if processes == -1: expected_statement.append('-n auto') expected_statement.append('--dist=loadscope') elif processes != 0: expected_statement.append('-n {}'.format(processes)) expected_statement.append('--dist=loadscope') expected_statement.extend([ "-p no:randomly", test_id ]) if run_under_coverage: if xdist_ip_addresses: for module in Env.covered_modules(): expected_statement.append('--cov') expected_statement.append(module) else: expected_statement.append('--cov') expected_statement.append('--cov-report=') return expected_statement
def _expected_command(self, root, test_id, pytestSubclass, run_under_coverage=True, processes=0, xdist_ip_addresses=None): """ Returns the command that is expected to be run for the given test spec and store. """ report_dir = Env.REPORT_DIR / root shard = os.environ.get('SHARD') if shard: report_dir = report_dir / 'shard_' + shard expected_statement = ["python", "-Wd", "-m", "pytest"] if pytestSubclass == "SystemTestSuite": expected_statement.append("--ds={}".format('{}.envs.{}'.format( root, Env.TEST_SETTINGS))) expected_statement.append("--junitxml={}".format(report_dir / "nosetests.xml")) if xdist_ip_addresses: expected_statement.append('--dist=loadscope') for ip in xdist_ip_addresses.split(','): if processes <= 0: processes = 1 if pytestSubclass == "SystemTestSuite": django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format( root) elif pytestSubclass == "LibTestSuite": if 'pavelib/paver_tests' in test_id: django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format( root) else: django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'" xdist_string = '--tx {}*ssh="ubuntu@{} -o StrictHostKeyChecking=no"' \ '//python="source /edx/app/edxapp/edxapp_env; {}; python"' \ '//chdir="/edx/app/edxapp/edx-platform"' \ .format(processes, ip, django_env_var_cmd) expected_statement.append(xdist_string) for rsync_dir in Env.rsync_dirs(): expected_statement.append('--rsyncdir {}'.format(rsync_dir)) else: if processes == -1: expected_statement.append('-n auto') expected_statement.append('--dist=loadscope') elif processes != 0: expected_statement.append('-n {}'.format(processes)) expected_statement.append('--dist=loadscope') expected_statement.extend(["-p no:randomly", test_id]) if run_under_coverage: if xdist_ip_addresses: for module in Env.covered_modules(): expected_statement.append('--cov') expected_statement.append(module) else: expected_statement.append('--cov') expected_statement.append('--cov-report=') return expected_statement