コード例 #1
0
def test_emit_loadenv_failure(user_runtime):
    snap = rt.snapshot()
    environ = env.Environment('test', modules=['testmod_foo', 'testmod_xxx'])

    # Suppress the module load error and verify that the original environment
    # is preserved
    with contextlib.suppress(EnvironError):
        rt.emit_loadenv_commands(environ)

    assert rt.snapshot() == snap
コード例 #2
0
ファイル: __init__.py プロジェクト: pramodk/reframe
    def prepare(self, commands, environs=None, **gen_opts):
        environs = environs or []
        if self.num_tasks <= 0:
            num_tasks_per_node = self.num_tasks_per_node or 1
            min_num_tasks = (-self.num_tasks
                             if self.num_tasks else num_tasks_per_node)

            try:
                guessed_num_tasks = self.guess_num_tasks()
            except NotImplementedError as e:
                raise JobError('flexible node allocation is not supported by '
                               'this backend') from e

            if guessed_num_tasks < min_num_tasks:
                raise JobError(
                    'could not satisfy the minimum task requirement: '
                    'required %s, found %s' %
                    (min_num_tasks, guessed_num_tasks))

            self.num_tasks = guessed_num_tasks
            getlogger().debug('flex_alloc_nodes: setting num_tasks to %s' %
                              self.num_tasks)

        with shell.generate_script(self.script_filename,
                                   **gen_opts) as builder:
            builder.write_prolog(self.scheduler.emit_preamble(self))
            builder.write(runtime.emit_loadenv_commands(*environs))
            for c in commands:
                builder.write_body(c)
コード例 #3
0
def test_emit_loadenv_commands(base_environ, user_runtime, modules_system,
                               env0):
    ms = rt.runtime().modules_system
    expected_commands = [
        ms.emit_load_commands('testmod_foo')[0],
        'export _var0=val1',
        'export _var2=$_var0',
        'export _var3=${_var1}',
    ]
    assert expected_commands == rt.emit_loadenv_commands(env0)
コード例 #4
0
 def test_emit_load_commands(self):
     self.setup_modules_system()
     ms = rt.runtime().modules_system
     expected_commands = [
         ms.emit_load_commands('testmod_foo')[0],
         'export _var0=val1',
         'export _var2=$_var0',
         'export _var3=${_var1}',
     ]
     assert expected_commands == rt.emit_loadenv_commands(self.environ)
コード例 #5
0
def test_emit_loadenv_commands_with_confict(base_environ, user_runtime,
                                            modules_system, env0):
    # Load a conflicting module
    modules_system.load_module('testmod_bar')
    ms = rt.runtime().modules_system
    expected_commands = [
        ms.emit_unload_commands('testmod_bar')[0],
        ms.emit_load_commands('testmod_foo')[0],
        'export _var0=val1',
        'export _var2=$_var0',
        'export _var3=${_var1}',
    ]
    assert expected_commands == rt.emit_loadenv_commands(env0)
コード例 #6
0
    def test_emit_load_commands_with_confict(self):
        self.setup_modules_system()

        # Load a conflicting module
        self.modules_system.load_module('testmod_bar')
        ms = rt.runtime().modules_system
        expected_commands = [
            ms.emit_unload_commands('testmod_bar')[0],
            ms.emit_load_commands('testmod_foo')[0],
            'export _var0=val1',
            'export _var2=$_var0',
            'export _var3=${_var1}',
        ]
        assert expected_commands == rt.emit_loadenv_commands(self.environ)
コード例 #7
0
def test_emit_loadenv_commands_mapping_with_conflict(base_environ,
                                                     user_runtime,
                                                     modules_system):
    if modules_system.name == 'tmod4':
        pytest.skip('test scenario not valid for tmod4')

    e0 = env.Environment(name='e0', modules=['testmod_ext'])
    ms = rt.runtime().modules_system
    ms.load_mapping('testmod_ext: testmod_ext testmod_foo')
    expected_commands = [
        ms.emit_load_commands('testmod_ext')[0],
        ms.emit_unload_commands('testmod_bar')[0],
        ms.emit_load_commands('testmod_foo')[0],
    ]
    assert expected_commands == rt.emit_loadenv_commands(e0)
コード例 #8
0
def test_emit_loadenv_commands_ignore_confict(base_environ,
                                              make_exec_ctx, env0):
    if not test_util.has_sane_modules_system():
        pytest.skip('no modules system configured')

    if test_util.USER_CONFIG_FILE:
        make_exec_ctx(test_util.USER_CONFIG_FILE, test_util.USER_SYSTEM,
                      options={'general/resolve_module_conflicts': False})
    else:
        make_exec_ctx(options={'general/resolve_module_conflicts': False})

    # Load a conflicting module
    ms = rt.runtime().modules_system
    with ms.change_module_path(test_util.TEST_MODULES):
        ms.load_module('testmod_bar')
        expected_commands = [
            ms.emit_load_commands('testmod_foo')[0],
            'export _var0=val1',
            'export _var2=$_var0',
            'export _var3=${_var1}',
        ]
        assert expected_commands == rt.emit_loadenv_commands(env0)