Exemplo n.º 1
0
def test_graph_sort():
    graph = TaskGraph()

    tasks = [
        coffee('combined.js', ['one.coffee', 'two.coffee']),
        coffee('other.js', ['three.coffee', 'four.coffee']),
        uglify('combined.min.js', ['combined.js', 'other.js']),
    ]

    for task in tasks:
        graph.arc(task)

    run_plan = list(graph.toposort())
    eq_(run_plan, [tasks[1], tasks[0], tasks[2]])
Exemplo n.º 2
0
def test_base():
    graph = TaskGraph()

    class coffee(Compiler):
        run = MagicMock()

    class uglify(Compiler):
        run = MagicMock()

    tasks = [
        uglify('static/js-c/home/signed_in.min.js', [
            'static/js-c/home/index.js',
            'static/js-lib/jquery-ui-1.8.23.custom-min.js',
            'static/js-lib/jquery.carousel.js',
            'static/js-c/common/tooltip.js',
            'static/js-c/common/carousel/carousel.js',
            'static/js-c/common/event_list/event_list.js',
            'static/js-c/home/signed_in.js',
        ]),
        coffee('static/js-c/home/index.js', ['static/js-c/home/index.coffee']),
        coffee('static/js-c/common/tooltip.js', ['static/js-c/common/tooltip.coffee']),
        coffee('static/js-c/common/carousel/carousel.js', ['static/js-c/common/carousel/carousel.coffee']),
        coffee('static/js-c/common/event_list/event_list.js', ['static/js-c/common/event_list/event_list.coffee']),
        coffee('static/js-c/home/signed_in.js', ['static/js-c/home/signed_in.coffee']),
    ]

    for task in tasks:
        graph.arc(task)

    run_plan = list(graph.toposort())
    eq_(run_plan[-1], tasks[0])

    runners = Scheduler().load(tasks).run()
    eq_(len(runners['static/js-c/home/signed_in.min.js'].waiting_for), 5)

    maker = Maker(*tasks)
    maker.executor = MockExecutor()
    maker.execute()

    eq_(len(maker.executor.executed), 6)
    # the last task executed should be uglify
    eq_(maker.executor.executed[-1].task, tasks[0])