Exemple #1
0
def test_build():
    box = Box.create(box1_path)
    box2 = Box.create(box2_path)

    foo_path = os.path.join(sourcedirs_path, 'foo')
    foo_source = SourceDir(foo_path)
    assert foo_source.path == foo_path
    bar_path = os.path.join(sourcedirs_path, 'bar')
    bar_source = SourceDir(bar_path)

    foo = foo_source.build(box)
    bar = bar_source.build(box)
    foo_new = foo_source.build(box, name_suffix='-new')

    assert foo.enabled == False
    assert foo_new.enabled == True

    assert os.path.samefile(os.path.join(box.virtual_path, 'lib', 'd', 'foo'),
                            os.path.join(foo_new.path, 'lib', 'd', 'foo'))

    assert foo_source.unittest() == True
    assert bar_source.unittest() == False

    foo_source.build(box2)  # Should clean before

    assert len(list(box.packages(only_enabled=True))) == 2

    box.disable_package(foo_new)
    assert not os.path.exists(os.path.join(box.virtual_path, 'lib', 'd',
                                           'foo'))

    foo_source.clean()
    bar_source.clean()
Exemple #2
0
def test_build():
    box = Box.create(box1_path)
    box2 = Box.create(box2_path)

    foo_path = os.path.join(sourcedirs_path, 'foo')
    foo_source = SourceDir(foo_path)
    assert foo_source.path == foo_path
    bar_path = os.path.join(sourcedirs_path, 'bar')
    bar_source = SourceDir(bar_path)

    foo = foo_source.build(box)
    bar = bar_source.build(box)
    foo_new = foo_source.build(box, name_suffix='-new')

    assert foo.enabled == False
    assert foo_new.enabled == True

    assert os.path.samefile(os.path.join(box.virtual_path, 'lib', 'd', 'foo'),
                            os.path.join(foo_new.path, 'lib', 'd', 'foo'))
    
    assert foo_source.unittest() == True
    assert bar_source.unittest() == False
    
    foo_source.build(box2) # Should clean before

    assert len(list(box.packages(only_enabled=True))) == 2

    box.disable_package(foo_new)
    assert not os.path.exists(os.path.join(box.virtual_path, 'lib', 'd', 'foo'))

    foo_source.clean()
    bar_source.clean()
Exemple #3
0
def main(argv, do_log=True):
    # set up default logging 
    # TODO(giuott): Add a verbosity option
    if do_log:
        logging.basicConfig()
        log.setLevel(logging.INFO)
    
    try:
        parser = setup_optparse()
        options, args = parser.parse_args(argv[1:])
    except ParserExit:
        return 0
    
    if not args:
        parser.print_help()
        return 255

    command = args[0]
    cmd_args = args[1:]
    config = Config()

    try:
        if options.box_path is not None:
            config.box = Box(options.box_path)
        else:
            config.box = get_current_box()
            if config.box is not None:
                log.info('Using current box "%s"', config.box.name)

        return ui.command.dispatch(command, config, cmd_args)
    except ui.command.CommandNotFound:
        log.error("Command %s not found", command)
        parser.print_help()
        return 255
    except bpt.UserError, exc:
        log.error('Aborting: %s', str(exc))
        return 1
Exemple #4
0
def test_packages():
    box = Box.create(box1_path)
    foo = box.create_package('foo-0.1', app_name='foo', app_version='0.1', enabled=True)
    bar = box.create_package('bar-0.2', app_name='bar', app_version='0.2', enabled=False)
    
    assert len(list(box.packages())) == 2
    l = list(box.packages(only_enabled=True))
    assert len(l) == 1
    assert l[0] is foo
    
    box.disable_package(foo)
    assert len(list(box.packages(only_enabled=True))) == 0
    
    box.enable_package(foo)
    box.enable_package(bar)
    assert len(list(box.packages(only_enabled=True))) == 2
    assert len(list(box.packages(only_enabled=True, matching=['foo.*']))) == 1

    box.disable_package(foo)
    assert len(list(box.packages(only_enabled=True, matching=['foo.*']))) == 0
    assert len(list(box.packages(matching=['foo.*']))) == 1
    
    box.disable_package(bar, remove=True)
    assert len(list(box.packages())) == 1
Exemple #5
0
def test_create():
    assert_raises(UserError, Box, box1_path) # No box, should raise
    box = Box.create(box1_path)
    assert box.path == box1_path
    assert_raises(UserError, Box.create, box1_path)
Exemple #6
0
    def _run(self, config, cmd_options, cmd_args):
        self._require_args(cmd_args, 1, 1)

        box_path = cmd_args[0]
        Box.create(box_path)
Exemple #7
0
    def _run(self, config, cmd_options, cmd_args):
        self._require_args(cmd_args, 1, 1)

        box_path = cmd_args[0]
        Box.create(box_path)