Пример #1
0
def test_get_compiler_link_paths_load_env(working_env, monkeypatch, tmpdir):
    gcc = str(tmpdir.join('gcc'))
    with open(gcc, 'w') as f:
        f.write("""#!/bin/bash
if [[ $ENV_SET == "1" && $MODULE_LOADED == "1" ]]; then
  echo '""" + no_flag_output + """'
fi
""")
    fs.set_executable(gcc)

    # Set module load to turn compiler on
    def module(*args):
        if args[0] == 'show':
            return ''
        elif args[0] == 'load':
            os.environ['MODULE_LOADED'] = "1"

    monkeypatch.setattr(spack.util.module_cmd, 'module', module)

    compiler = MockCompiler()
    compiler.environment = {'set': {'ENV_SET': '1'}}
    compiler.modules = ['turn_on']

    dirs = compiler._get_compiler_link_paths([gcc])
    assert dirs == no_flag_dirs
Пример #2
0
def test_get_compiler_link_paths_no_path():
    compiler = MockCompiler()
    compiler.cc = None
    compiler.cxx = None
    compiler.f77 = None
    compiler.fc = None

    dirs = compiler._get_compiler_link_paths([compiler.cxx])
    assert dirs == []
Пример #3
0
def test_get_compiler_link_paths(monkeypatch, exe, flagname):
    # create fake compiler that emits mock verbose output
    compiler = MockCompiler()
    monkeypatch.setattr(
        spack.util.executable.Executable, '__call__', call_compiler)

    # Grab executable path to test
    paths = [getattr(compiler, exe)]

    # Test without flags
    dirs = compiler._get_compiler_link_paths(paths)
    assert dirs == no_flag_dirs

    if flagname:
        # set flags and test
        setattr(compiler, 'flags', {flagname: ['--correct-flag']})
        dirs = compiler._get_compiler_link_paths(paths)
        assert dirs == flag_dirs
Пример #4
0
def test_get_compiler_link_paths_no_verbose_flag():
    compiler = MockCompiler()
    compiler._verbose_flag = None

    dirs = compiler._get_compiler_link_paths([compiler.cxx])
    assert dirs == []