コード例 #1
0
def test_dependency_resolution_8():
    """ Position of singleton thing """

    a0 = Thing('a0.js', [])
    a1 = Thing('a1.js', ['b1.js', 'b2.js'])
    b1 = Thing('b1.js', ['c1.js'])
    b2 = Thing('b2.js', ['d1.js'])
    c1 = Thing('c1.js', ['d1.js'])
    d1 = Thing('d1.js', [])

    # Stay in front
    #    \/
    aa = a0, a1, b1, b2, c1, d1
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['a0.js', 'd1.js', 'c1.js', 'b1.js', 'b2.js', 'a1.js']

    # Get send to back - after a1, and a1 gets send to back due to its deps
    #        \/
    aa = a1, a0, b1, b2, c1, d1
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['d1.js', 'c1.js', 'b1.js', 'b2.js', 'a1.js', 'a0.js']

    # Stay behind b1
    #        \/
    aa = b1, a0, a1, b2, c1, d1
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['d1.js', 'c1.js', 'b1.js', 'a0.js', 'b2.js', 'a1.js']
コード例 #2
0
def test_dependency_resolution_5():
    """ Two chains """

    a1 = Thing('a1.js', ['b1.js'])
    b1 = Thing('b1.js', ['c1.js'])
    c1 = Thing('c1.js', ['d1.js'])

    a2 = Thing('a2.js', ['b2.js'])
    b2 = Thing('b2.js', ['c2.js'])
    c2 = Thing('c2.js', ['d2.js'])

    # First the chain 1
    aa = a1, b1, c1, a2, b2, c2
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['c1.js', 'b1.js', 'a1.js', 'c2.js', 'b2.js', 'a2.js']

    # First the chain 2
    aa = a2, b2, c2, a1, b1, c1
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['c2.js', 'b2.js', 'a2.js', 'c1.js', 'b1.js', 'a1.js']

    # Mix, put el from chain 1 first
    aa = a1, a2, b1, b2, c1, c2
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['c1.js', 'b1.js', 'a1.js', 'c2.js', 'b2.js', 'a2.js']

    # Mix, put el from chain 2 first
    aa = a2, a1, b1, b2, c1, c2
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['c2.js', 'b2.js', 'a2.js', 'c1.js', 'b1.js', 'a1.js']
コード例 #3
0
def test_dependency_resolution_1():
    """ No deps, maintain order. """

    a1 = Thing('a1.js', [])
    a2 = Thing('a2.js', [])
    a3 = Thing('a3.js', [])

    aa = a1, a2, a3
    aa = solve_dependencies(aa)
    assert [a.name for a in aa] == ['a1.js', 'a2.js', 'a3.js']
コード例 #4
0
def test_dependency_resolution_4():
    """ Circular deps """

    a1 = Thing('a1.js', ['b1.js'])
    b1 = Thing('b1.js', ['c1.js'])
    c1 = Thing('c1.js', ['d1.js'])
    d1 = Thing('d1.js', ['e1.js', 'a1.js'])
    e1 = Thing('e1.js', [])

    aa = a1, b1, c1, d1, e1
    with raises(RuntimeError):
        aa = solve_dependencies(aa)
コード例 #5
0
def test_dependency_resolution_2():
    """ One chain of deps """

    a1 = Thing('a1.js', ['b1.js'])
    b1 = Thing('b1.js', ['c1.js'])
    c1 = Thing('c1.js', ['d1.js'])
    d1 = Thing('d1.js', ['e1.js'])
    e1 = Thing('e1.js', [])
    # e1 = Thing('e1.js', '', ['f1.js'])
    # f1 = Thing('f1.js', '', ['g1.js'])
    # g1 = Thing('g1.js', '', [])

    aa = a1, b1, c1, d1, e1
    aa = solve_dependencies(aa)
    assert [a.name
            for a in aa] == ['e1.js', 'd1.js', 'c1.js', 'b1.js', 'a1.js']

    aa = a1, d1, e1, b1, c1
    aa = solve_dependencies(aa)
    assert [a.name
            for a in aa] == ['e1.js', 'd1.js', 'c1.js', 'b1.js', 'a1.js']
コード例 #6
0
def test_dependency_resolution_7():
    """ Shared deps """

    a1 = Thing('a1.js', ['b1.js', 'b2.js'])
    b1 = Thing('b1.js', ['c1.js'])
    b2 = Thing('b2.js', ['d1.js'])
    c1 = Thing('c1.js', ['d1.js'])
    d1 = Thing('d1.js', [])

    aa = a1, b1, b2, c1, d1
    aa = solve_dependencies(aa)
    assert [a.name
            for a in aa] == ['d1.js', 'c1.js', 'b1.js', 'b2.js', 'a1.js']
コード例 #7
0
def test_dependency_resolution_6():
    """ Multiple deps - order """

    a1 = Thing('a1.js', ['b1.js', 'b2.js'])
    b1 = Thing('b1.js', ['c1.js', 'c2.js'])
    b2 = Thing('b2.js', ['c2.js', 'c3.js'])
    c1 = Thing('c1.js', [])
    c2 = Thing('c2.js', [])
    c3 = Thing('c3.js', [])

    aa = a1, b1, b2, c1, c2, c3
    aa = solve_dependencies(aa)
    assert [a.name for a in aa
            ] == ['c1.js', 'c2.js', 'b1.js', 'c3.js', 'b2.js', 'a1.js']
コード例 #8
0
def test_dependency_resolution_3():
    """ Unkown deps are ignored (but warned for) """

    a1 = Thing('a1.js', ['b1.js'])
    b1 = Thing('b1.js', ['bar.js', 'c1.js'])
    c1 = Thing('c1.js', ['d1.js', 'foo.js'])
    d1 = Thing('d1.js', ['e1.js'])
    e1 = Thing('e1.js', [])

    aa = a1, b1, c1, d1, e1
    with capture_log('warning') as logs:
        aa = solve_dependencies(aa, warn_missing=True)
    assert logs and 'missing dependency' in logs[0]
    assert [a.name
            for a in aa] == ['e1.js', 'd1.js', 'c1.js', 'b1.js', 'a1.js']