Example #1
0
    def test_module_common_operations(self):
        parser = argparse.ArgumentParser()
        module.setup_parser(parser)

        # Try to remove a non existing module [tcl]
        args = parser.parse_args(['rm', 'doesnotexist'])
        self.assertRaises(SystemExit, module.module, parser, args)

        # Remove existing modules [tcl]
        args = parser.parse_args(['rm', '-y', 'mpileaks'])
        module_files = self._get_module_files(args)
        for item in module_files:
            self.assertTrue(os.path.exists(item))
        module.module(parser, args)
        for item in module_files:
            self.assertFalse(os.path.exists(item))

        # Add them back [tcl]
        args = parser.parse_args(['refresh', '-y', 'mpileaks'])
        module.module(parser, args)
        for item in module_files:
            self.assertTrue(os.path.exists(item))

        # TODO : test the --delete-tree option
        # TODO : this requires having a separate directory for test modules

        # Try to find a module with multiple matches
        args = parser.parse_args(['find', 'mpileaks'])
        self.assertRaises(SystemExit, module.module, parser, args)

        # Try to find a module with no matches
        args = parser.parse_args(['find', 'doesnotexist'])
        self.assertRaises(SystemExit, module.module, parser, args)

        # Try to find a module
        args = parser.parse_args(['find', 'libelf'])
        module.module(parser, args)

        # Remove existing modules [dotkit]
        args = parser.parse_args(['rm', '-y', '-m', 'dotkit', 'mpileaks'])
        module_files = self._get_module_files(args)
        for item in module_files:
            self.assertTrue(os.path.exists(item))
        module.module(parser, args)
        for item in module_files:
            self.assertFalse(os.path.exists(item))

        # Add them back [dotkit]
        args = parser.parse_args(['refresh', '-y', '-m', 'dotkit', 'mpileaks'])
        module.module(parser, args)
        for item in module_files:
            self.assertTrue(os.path.exists(item))
Example #2
0
def test_remove_and_add_dotkit(database, parser):
    # Remove existing modules [dotkit]
    args = parser.parse_args(['rm', '-y', '-m', 'dotkit', 'mpileaks'])
    module_files = _get_module_files(args)
    for item in module_files:
        assert os.path.exists(item)
    module.module(parser, args)
    for item in module_files:
        assert not os.path.exists(item)

    # Add them back [dotkit]
    args = parser.parse_args(['refresh', '-y', '-m', 'dotkit', 'mpileaks'])
    module.module(parser, args)
    for item in module_files:
        assert os.path.exists(item)
Example #3
0
File: module.py Project: zepx/spack
def test_remove_and_add_dotkit(database, parser):
    # Remove existing modules [dotkit]
    args = parser.parse_args(['rm', '-y', '-m', 'dotkit', 'mpileaks'])
    module_files = _get_module_files(args)
    for item in module_files:
        assert os.path.exists(item)
    module.module(parser, args)
    for item in module_files:
        assert not os.path.exists(item)

    # Add them back [dotkit]
    args = parser.parse_args(['refresh', '-y', '-m', 'dotkit', 'mpileaks'])
    module.module(parser, args)
    for item in module_files:
        assert os.path.exists(item)
def test_remove_and_add_tcl(database, parser):
    """Tests adding and removing a tcl module file."""

    # Remove existing modules [tcl]
    args = parser.parse_args(['rm', '-y', '-m', 'tcl', 'mpileaks'])
    module_files = _get_module_files(args)

    for item in module_files:
        assert os.path.exists(item)

    module.module(parser, args)

    for item in module_files:
        assert not os.path.exists(item)

    # Add them back [tcl]
    args = parser.parse_args(['refresh', '-y', '-m', 'tcl', 'mpileaks'])
    module.module(parser, args)

    for item in module_files:
        assert os.path.exists(item)
def test_find(database, parser):
    """Tests the 'spack module find' under a few common scenarios."""

    # Try to find it for tcl module files
    args = parser.parse_args(['find', '--module-type', 'tcl', 'libelf'])
    module.module(parser, args)
def test_exit_with_failure(database, parser, failure_args):
    args = parser.parse_args(failure_args)
    with pytest.raises(SystemExit):
        module.module(parser, args)
Example #7
0
def test_find(parser, cli_args):
    """Tests the 'spack module find' under a few common scenarios."""

    # Try to find it for tcl module files
    args = parser.parse_args(['find'] + cli_args)
    module.module(parser, args)
Example #8
0
def test_find(database, parser):
    # Try to find a module
    args = parser.parse_args(['find', 'libelf'])
    module.module(parser, args)
Example #9
0
def test_exit_with_failure(database, parser, failure_args):
    args = parser.parse_args(failure_args)
    with pytest.raises(SystemExit):
        module.module(parser, args)
Example #10
0
File: module.py Project: zepx/spack
def test_find(database, parser):
    # Try to find a module
    args = parser.parse_args(['find', 'libelf'])
    module.module(parser, args)