Esempio n. 1
0
def tree(chtempdir):
    '''
    A directory tree with our fixture data and appropriate scripts.

    Contents:
    * A mocked-out `flow` command, as a script that cats a file.
    * The said file, computed from the fixture data.
    * Stub source files, with `@flow` lines for `grep` to find,
      computed also from fixture data.
    * The reference script `tsort-modules.orig`, copied into place.
    '''
    for filename, imports in import_graph.items():
        check_cmd('mkdir -p {}', os.path.dirname(filename))
        with open(filename, 'w') as f:
            print(flow_line.get(filename, ''), file=f)

    with open('imports.json', 'w') as f:
        json.dump(compute_json(), f)

    check_cmd('mkdir -p node_modules/.bin')
    with open('node_modules/.bin/flow', 'w') as f:
        f.write('#!/bin/bash\ncat imports.json\n')
    check_cmd('chmod a+x node_modules/.bin/flow')

    check_cmd('mkdir -p tools')
    check_cmd('cp -a {}/tsort-modules.orig tools/tsort-modules', THIS_DIR)
Esempio n. 2
0
def test_originfallback():
    check_cmd("git update-ref refs/remotes/origin/datacomp datacomp")
    check_cmd("git update-ref -d refs/heads/datacomp")
    check_cmd("git log --graph --oneline --all @")

    check_cmd("{} brown-dwarf", knit_script)

    check_cmd("git log --graph --oneline --all @")
    assert slurp_cmd("git log -n1 --format=%p @").split(b" ") == [
        slurp_cmd("git rev-parse --short master"),
        slurp_cmd("git rev-parse --short origin/datacomp"),
    ]
Esempio n. 3
0
def test_include_optional():
    check_cmd("git checkout @^ -b brown-dwarf.only")
    example_ci("b")
    check_cmd("git checkout master")
    check_cmd("git log --graph --oneline --all @")

    check_cmd("{} brown-dwarf", knit_script)

    check_cmd("git log --graph --oneline --all @")
    assert slurp_cmd("git log -n1 --format=%p @").split(b" ") == [
        slurp_cmd("git rev-parse --short master"),
        slurp_cmd("git rev-parse --short datacomp"),
        slurp_cmd("git rev-parse --short brown-dwarf.only"),
    ]
Esempio n. 4
0
def test_fail_on_branch_missing():
    check_cmd("git update-ref -d refs/heads/datacomp")
    check_cmd("git log --graph --oneline --all @")

    with pytest.raises(subprocess.CalledProcessError):
        check_cmd("{} brown-dwarf", knit_script)

    check_cmd("git log --graph --oneline --all @")
    assert slurp_cmd("git rev-parse @") \
        == slurp_cmd("git rev-parse master")
Esempio n. 5
0
def test_dirty():
    with open("a", "a") as f:
        f.write("aa\n")
    check_cmd("git log --graph --oneline --all @")

    with pytest.raises(subprocess.CalledProcessError):
        check_cmd("{} brown-dwarf", knit_script)

    check_cmd("git log --graph --oneline --all @")
    assert slurp_cmd("git rev-parse @") \
        == slurp_cmd("git rev-parse master")
Esempio n. 6
0
def test_basic_happy():
    check_cmd("git log --graph --oneline --all @")

    check_cmd("{} brown-dwarf", knit_script)

    check_cmd("git log --graph --oneline --all @")
    parents = \
        slurp_cmd("git log -n1 --format=%p @").split(b" ")
    assert parents == [
        slurp_cmd("git rev-parse --short master"),
        slurp_cmd("git rev-parse --short datacomp"),
    ]
Esempio n. 7
0
def repo(chtempdir):
    """
    * (master) m
    |
    | * (datacomp) d
    |/
    * a
    """
    check_cmd("git init")
    example_ci("a")
    example_ci("m")
    check_cmd("git checkout @^ -b datacomp")
    example_ci("d")
    check_cmd("git checkout master")
Esempio n. 8
0
def example_ci(name):
    with open(name, "w") as f:
        f.write(f"{name}\n")
    check_cmd("git add {}", name)
    check_cmd("git commit -m {}", name)