コード例 #1
0
ファイル: test_cli.py プロジェクト: itkovian/reframe
def run_command_inline(argv, funct, *args, **kwargs):
    # Save current execution context
    argv_save = sys.argv
    environ_save = EnvironmentSnapshot()
    sys.argv = argv
    exitcode = None

    captured_stdout = StringIO()
    captured_stderr = StringIO()
    print(*sys.argv)
    with redirect_stdout(captured_stdout):
        with redirect_stderr(captured_stderr):
            try:
                with rt.temp_runtime(None):
                    exitcode = funct(*args, **kwargs)
            except SystemExit as e:
                exitcode = e.code
            finally:
                # Restore execution context
                environ_save.load()
                sys.argv = argv_save

    return (exitcode,
            captured_stdout.getvalue(),
            captured_stderr.getvalue())
コード例 #2
0
 def __init__(self, policy, printer=None, max_retries=0):
     self._policy = policy
     self._printer = printer or PrettyPrinter()
     self._max_retries = max_retries
     self._stats = TestStats()
     self._policy.stats = self._stats
     self._policy.printer = self._printer
     self._sandbox = Sandbox()
     self._environ_snapshot = EnvironmentSnapshot()
コード例 #3
0
    def run_check(self, check, partition, environ):
        try:
            executor = RegressionTestExecutor(check, self.strict_check)
            testcase = TestCase(executor)

            executor.setup(partition=partition,
                           environ=environ,
                           sched_account=self.sched_account,
                           sched_partition=self.sched_partition,
                           sched_reservation=self.sched_reservation,
                           sched_nodelist=self.sched_nodelist,
                           sched_exclude_nodelist=self.sched_exclude_nodelist,
                           sched_options=self.sched_options)

            ready_testcase = RunningTestCase(testcase, EnvironmentSnapshot())
            partname = partition.fullname
            if self._running_cases_counts[partname] >= partition.max_jobs:
                # Make sure that we still exceeded the job limit
                getlogger().debug('reached job limit (%s) for partition %s' %
                                  (partition.max_jobs, partname))
                self._update_running_counts()

            if self._running_cases_counts[partname] < partition.max_jobs:
                # Test's environment is already loaded; no need to be reloaded
                self._reschedule(ready_testcase, load_env=False)
            else:
                self._print_executor_status('HOLD', executor)
                self._ready_cases[partname].append(ready_testcase)

        except (KeyboardInterrupt, ReframeFatalError, AssertionError):
            if not testcase.failed():
                # test case failed during setup
                testcase.fail(sys.exc_info())
            self._failall()
            raise
        except:
            # Here we are sure that test case has failed during setup, since
            # _compile_and_run() handles already non-fatal exceptions. Though
            # we check again the testcase, just in case.
            if not testcase.failed():
                testcase.fail(sys.exc_info())
        finally:
            if testcase.valid() and testcase.failed_stage == 'setup':
                # We need to print the result here only if the setup stage has
                # finished, since otherwise _compile_and_run() prints it
                self.printer.result(executor.check, partition, environ,
                                    not testcase.failed())

            self._test_cases.append(testcase)
            self.environ_snapshot.load()
コード例 #4
0
ファイル: __init__.py プロジェクト: bcfriesen/reframe
    def __init__(self):
        # Options controlling the check execution
        self.skip_system_check = False
        self.force_local = False
        self.skip_environ_check = False
        self.skip_sanity_check = False
        self.skip_performance_check = False
        self.keep_stage_files = False
        self.only_environs = None
        self.printer = None
        self.environ_snapshot = EnvironmentSnapshot()
        self.strict_check = False

        # Scheduler options
        self.sched_account = None
        self.sched_partition = None
        self.sched_reservation = None
        self.sched_nodelist = None
        self.sched_exclude_nodelist = None
        self.sched_options = []
コード例 #5
0
ファイル: pipeline.py プロジェクト: GiuseppeLoRe/reframe
    def _setup_environ(self, environ):
        """Setup the current environment and load it."""

        self._current_environ = environ

        # Set up user environment
        self._user_environ = Environment(
            type(self).__name__, self.modules, self.variables.items())

        # Temporarily load the test's environment to record the actual module
        # load/unload sequence
        environ_save = EnvironmentSnapshot()
        # First load the local environment of the partition
        self.logger.debug('loading environment for the current partition')
        self._current_partition.local_env.load()

        self.logger.debug("loading current programming environment")
        self._current_environ.load()

        self.logger.debug("loading user's environment")
        self._user_environ.load()
        environ_save.load()
コード例 #6
0
ファイル: test_cli.py プロジェクト: lxavier/reframe
def run_command_inline(argv, funct, *args, **kwargs):
    argv_save = sys.argv
    environ_save = EnvironmentSnapshot()
    captured_stdout = StringIO()
    captured_stderr = StringIO()
    sys.argv = argv
    exitcode = None
    print(' '.join(argv))
    with redirect_stdout(captured_stdout):
        with redirect_stderr(captured_stderr):
            try:
                exitcode = funct(*args, **kwargs)
            except SystemExit as e:
                exitcode = e.code
            finally:
                # restore environment, command-line arguments, and the native
                # modules system
                environ_save.load()
                sys.argv = argv_save
                fixtures.init_native_modules_system()

    return (exitcode, captured_stdout.getvalue(), captured_stderr.getvalue())
コード例 #7
0
 def setup(self, *args, **kwargs):
     self._safe_call(self._check.setup, *args, **kwargs)
     self._environ = EnvironmentSnapshot()
コード例 #8
0
 def setUp(self):
     self.environ_save = EnvironmentSnapshot()
     self.modules_system.searchpath_add(TEST_MODULES)