Exemplo n.º 1
0
def test_progenv_construction():
    environ = env.ProgEnvironment('myenv',
                                  modules=['modfoo'],
                                  variables=[('var', 'val')],
                                  extras={'foo': 'bar'})
    assert environ.name == 'myenv'
    assert environ.modules == ['modfoo']
    assert environ.variables == {'var': 'val'}
    assert environ.extras == {'foo': 'bar'}
Exemplo n.º 2
0
 def test_compile(self):
     # Compile a 'Hello, World' with the builtin gcc/g++
     env = renv.ProgEnvironment(name='builtin-gcc',
                                cc='gcc', cxx='g++', ftn=None)
     try:
         self.compile_with_env(env, skip_fortran=True)
         self.compile_dir_with_env(env, skip_fortran=True)
     except CompilationError as e:
         self.fail("Compilation failed\n")
Exemplo n.º 3
0
        def create_env(system, partition, name):
            # Create an environment instance
            try:
                config = envconfig['%s:%s:%s' % (system, partition, name)]
            except KeyError:
                raise ConfigError("could not find a definition for `%s'" %
                                  name) from None

            if not isinstance(config, collections.abc.Mapping):
                raise TypeError("config for `%s' is not a dictionary" % name)

            return m_env.ProgEnvironment(name, **config)
Exemplo n.º 4
0
    def test_immutability(self):
        # Check emit_load_commands()
        commands = self.environ.emit_load_commands()
        self.assertIsNot(commands, self.environ.emit_load_commands())
        self.assertEqual(commands, self.environ.emit_load_commands())

        # Try to modify the returned list of commands
        commands.append('foo')
        self.assertNotIn('foo', self.environ.emit_load_commands())

        # Test ProgEnvironment
        prgenv = renv.ProgEnvironment('foo_prgenv')
        self.assertIsInstance(prgenv, renv.Environment)
        with self.assertRaises(AttributeError):
            prgenv.cc = 'gcc'

        with self.assertRaises(AttributeError):
            prgenv.cxx = 'g++'

        with self.assertRaises(AttributeError):
            prgenv.ftn = 'gfortran'

        with self.assertRaises(AttributeError):
            prgenv.nvcc = 'clang'

        with self.assertRaises(AttributeError):
            prgenv.cppflags = ['-DFOO']

        with self.assertRaises(AttributeError):
            prgenv.cflags = ['-O1']

        with self.assertRaises(AttributeError):
            prgenv.cxxflags = ['-O1']

        with self.assertRaises(AttributeError):
            prgenv.fflags = ['-O1']

        with self.assertRaises(AttributeError):
            prgenv.ldflags = ['-lm']
Exemplo n.º 5
0
def test_env_immutability(base_environ, env0):
    # Check emitted commands
    _, commands = rt.loadenv(env0)

    # Try to modify the returned list of commands
    commands.append('foo')
    assert 'foo' not in rt.loadenv(env0)[1]

    # Test ProgEnvironment
    prgenv = env.ProgEnvironment('foo_prgenv')
    assert isinstance(prgenv, env.Environment)
    with pytest.raises(AttributeError):
        prgenv.cc = 'gcc'

    with pytest.raises(AttributeError):
        prgenv.cxx = 'g++'

    with pytest.raises(AttributeError):
        prgenv.ftn = 'gfortran'

    with pytest.raises(AttributeError):
        prgenv.nvcc = 'clang'

    with pytest.raises(AttributeError):
        prgenv.cppflags = ['-DFOO']

    with pytest.raises(AttributeError):
        prgenv.cflags = ['-O1']

    with pytest.raises(AttributeError):
        prgenv.cxxflags = ['-O1']

    with pytest.raises(AttributeError):
        prgenv.fflags = ['-O1']

    with pytest.raises(AttributeError):
        prgenv.ldflags = ['-lm']