예제 #1
0
def test_deploy_to_gcloud_app(gitrepo, gcloudecho):
    files = [('rever.xsh', GCLOUD_APP_REVER_XSH),
             ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    env_main(['0.1.0'])
예제 #2
0
def test_conda_forge_activity(gitrepo, gitecho):
    vcsutils.tag("0.0.1")
    env = builtins.__xonsh__.env
    recipe_dir = os.path.join(env["REVER_DIR"], "rever-feedstock", "recipe")
    meta_yaml = os.path.join(recipe_dir, "meta.yaml")
    os.makedirs(recipe_dir, exist_ok=True)
    files = [
        ("rever.xsh", REVER_XSH),
        (meta_yaml, ORIG_META_YAML),
        ("credfile", CREDFILE),
    ]
    for filename, body in files:
        with open(filename, "w") as f:
            f.write(body)
    vcsutils.track(".")
    vcsutils.commit("Some versioned files")
    env_main(["0.1.0"])
    # now see if this works
    with open(meta_yaml, "r") as f:
        obs = f.read()
    assert EXP_META_YAML == obs

    env_main(["0.2.0"])
    # now see if this works
    with open(meta_yaml, "r") as f:
        obs = f.read()
    assert EXP_META_YAML2 == obs
예제 #3
0
def test_authors(gitrepo):
    vcsutils.tag('42.1.0')
    files = [
        ('rever.xsh', REVER_XSH),
    ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('initial authors')
    env_main(['42.1.1'])
    # now see if this worked
    files = os.listdir('.')
    assert 'AUTHORS.md' in files
    assert 'authors.yaml' in files
    assert 'Mailmap' in files
    assert 'latest.json' in files
    # test authors file
    with open('AUTHORS.md') as f:
        auth = f.read()
    assert auth.startswith(
        "All of the people who have made at least one contribution to WAKKA.\n"
        "Authors are sorted by number of commits.\n")
    # test latest file
    with open("latest.json") as f:
        latest = json.load(f)
    assert isinstance(latest, list)
    assert len(latest) == 1
    assert isinstance(latest[0], str)
    assert '@' in latest[0]
    # ensure that the updates were commited
    logger = current_logger()
    entries = logger.load()
    assert entries[-2]['rev'] != entries[-1]['rev']
예제 #4
0
def test_changelog(gitrepo):
    os.makedirs('nuws', exist_ok=True)
    files = [('rever.xsh', REVER_XSH),
             ('CHANGELOG.rst', CHANGELOG_RST),
             ('nuws/TEMPLATE.rst', TEMPLATE_RST),
             ('nuws/n0.rst', N0_RST),
             ('nuws/n1.rst', N1_RST),
             ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('initial changelog and news')
    env_main(['42.1.1'])
    # now see if this worked
    newsfiles = os.listdir('nuws')
    assert 'TEMPLATE.rst' in newsfiles
    assert 'n0.rst' not in newsfiles
    assert 'n1.rst' not in newsfiles
    with open('CHANGELOG.rst') as f:
        cl = f.read()
    assert CHANGELOG_42_1_1 == cl
    # ensure that the updates were commited
    logger = current_logger()
    entries = logger.load()
    assert entries[-2]['rev'] != entries[-1]['rev']
예제 #5
0
def test_dont_redo_deps(gitrepo):
    # This test runs an activity a, then runs an activity b that depends on a
    # During the second run, a should not be rerun since it was already
    # run the first time.
    env = builtins.__xonsh__.env
    dag = env['DAG']
    a = dag['a'] = Activity(name='a')
    b = dag['b'] = Activity(name='b', deps={'a'})
    # run the first time
    env_main(args=['--activities', 'a', 'x.y.z'])
    done = compute_activities_completed()
    assert done == {'a'}
    # test what we we need to run if we wanted to run b
    path, already_done = compute_activities_to_run(activities=['b'])
    assert path == ['b']
    assert already_done == ['a']
    # run for the second time
    env_main(args=['--activities', 'b', 'x.y.z'])
    done = compute_activities_completed()
    assert done == {'a', 'b'}
    # make sure a and b were each run exactly once
    entries = env['LOGGER'].load()
    a_ends = [
        e for e in entries
        if e['activity'] == 'a' and e['category'] == 'activity-end'
    ]
    assert len(a_ends) == 1
    b_ends = [
        e for e in entries
        if e['activity'] == 'b' and e['category'] == 'activity-end'
    ]
    assert len(b_ends) == 1
예제 #6
0
def test_activities_from_cli(gitrepo):
    with open('rever.xsh', 'w') as f:
        f.write('$ACTIVITIES = ["a", "b", "c"]\n')
    env = builtins.__xonsh__.env
    env['DAG'] = defaultdict(Activity)
    env_main(args=['-a', 'e,f,g', 'x.y.z'])
    assert env['ACTIVITIES'] == ["e", "f", "g"]
    assert env['RUNNING_ACTIVITIES'] == ["e", "f", "g"]
예제 #7
0
def test_activities_from_entrypoint(gitrepo):
    with open('rever.xsh', 'w') as f:
        f.write('$ACTIVITIES = ["a", "b", "c"]\n'
                '$ACTIVITIES_ALT = ["e", "f", "g"]\n')
    env = builtins.__xonsh_env__
    env['DAG'] = defaultdict(Activity)
    env_main(args=['-e', 'alt', 'x.y.z'])
    assert env['ACTIVITIES'] == ["a", "b", "c"]
    assert env['RUNNING_ACTIVITIES'] == ["e", "f", "g"]
예제 #8
0
def test_bibtex_activity(gitrepo):
    files = [
        ('rever.xsh', REVER_XSH),
    ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    env_main(['42.1.1'])
    # now see if this worked
    assert 'bibtex.bib' in os.listdir('.')
예제 #9
0
def test_version_in_config(gitrepo):
    with open('rever.xsh', 'w') as f:
        f.write(VERSION_IN_CONFIG)
    env = builtins.__xonsh__.env
    vstr = '42.43.44'
    env_main(args=[vstr])
    assert os.path.isfile('ver.txt')
    with open('ver.txt') as f:
        version = f.read()
    assert vstr == version
예제 #10
0
def test_appimage(gitrepo):
    Path('appimage').mkdir(exist_ok=True)
    files = [('rever.xsh', REVER_XSH), ('setup.py', SETUP_FILE),
             ('appimage/entrypoint.sh', APPIMAGE_ENTRYPOINT_FILE),
             ('appimage/pre-requirements.txt', APPIMAGE_PRE_REQUIREMENTS_FILE),
             ('appimage/xonsh.appdata.xml', APPIMAGE_APPDATA_FILE),
             ('appimage/xonsh.desktop', APPIMAGE_DESKTOP_FILE)]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('Some versioned files')
    env_main(['42.1.1'])
    assert Path('xonsh-x86_64.AppImage') in Path('.').glob('*')
예제 #11
0
def test_bad_activities_break(gitrepo):
    with open('rever.xsh', 'w') as f:
        f.write(BAD_GOOD)
    env = builtins.__xonsh__.env
    try:
        env_main(args=['x.y.z'])
        completed = True
    except SystemExit:
        completed = False
    assert not completed
    assert not os.path.isfile('good')
    logger = current_logger()
    for entry in logger.load():
        assert entry['activity'] != 'good'
예제 #12
0
def test_pypi_activity(gitrepo):
    files = [('rever.xsh', REVER_XSH), ('pypirc', VALID_RC),
             ('setup.py', SETUP_PY)]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('Some versioned files')
    env_main(['42.1.1'])
    env = builtins.__xonsh__.env
    python = env.get('PYTHON')
    out = subprocess.check_output([python, 'setup.py', '--version'],
                                  universal_newlines=True)
    out = out.strip()
    assert '42.1.1' == out
예제 #13
0
def test_command_activity(gitrepo):
    files = [
        ('rever.xsh', REVER_XSH),
    ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('Some versioned files')

    env_main(['42.1.1'])
    # now see if this worked
    assert os.path.exists('test')
    # now try to undo the tag
    env_main(['-u', 'test_command', '42.1.1'])
    assert not os.path.exists('test')
예제 #14
0
def test_changelog_setup(gitrepo):
    files = [
        ('rever.xsh', SETUP_XSH),
    ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('initial authors')
    env_main(['setup'])
    # now see if this worked
    files = os.listdir('.')
    assert 'AUTHORS.md' in files
    assert 'Mailmap' in files
    with open('AUTHORS.md') as f:
        auth = f.read()
    assert 'My project is castlehouse\n' == auth
예제 #15
0
def test_version_bump(gitrepo):
    files = [('rever.xsh', REVER_XSH), ('init.py', INIT_PY),
             ('appveyor.yml', APPVEYOR_YML)]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('Some versioned files')
    env_main(['42.1.1'])
    # now see if this worked
    with open('init.py') as f:
        init = f.read()
    assert "__version__ = '42.1.1'\n" == init
    with open('appveyor.yml') as f:
        appveyor = f.read()
    assert appveyor == "version: 42.1.1.{build}\n"
    # ensure that the updates were commited
    logger = current_logger()
    entries = logger.load()
    assert entries[-2]['rev'] != entries[-1]['rev']
예제 #16
0
def test_version_act_completed(gitrepo):
    # This test runs an activity a, undoes a, then runs an activity b that depends on a
    # During the last run, a should not be rerun since it was already
    # run the first time.
    with open('rever.xsh', 'w') as f:
        f.write(EMPTY_REVER_XSH)
    env = builtins.__xonsh__.env
    dag = env['DAG']
    a = dag['a'] = Activity(name='a')
    b = dag['b'] = Activity(name='b', deps={'a'})
    # run the first time
    env_main(args=['--activities', 'a', 'x.y.z'])
    done = compute_activities_completed()
    assert done == {'a'}
    # Now that we changed the version the activity is not done
    env['VERSION'] = 'x.y.zz'
    done = compute_activities_completed()
    assert done == set()

    env_main(args=['--activities', 'a', 'x.y.zz'])
    done = compute_activities_completed()
    assert done == set('a')

    env_main(args=['--undo', 'a', 'x.y.z'])
    done = compute_activities_completed()
    assert done == set()

    env['VERSION'] = 'x.y.zz'
    done = compute_activities_completed()
    assert done == set('a')
예제 #17
0
def test_changelog_setup(gitrepo):
    os.makedirs('nuws', exist_ok=True)
    files = [('rever.xsh', SETUP_XSH),
             ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('initial changelog')
    env_main(['setup'])
    # now see if this worked
    newsfiles = os.listdir('nuws')
    assert 'TEMPLATE.rst' in newsfiles
    basefiles = os.listdir('.')
    assert 'CHANGELOG.rst' in basefiles
    with open('CHANGELOG.rst') as f:
        cl = f.read()
    assert 'castlehouse' in cl
    assert '.gitignore' in basefiles
    with open('.gitignore') as f:
        gi = f.read()
    assert '\n# Rever\nrvr/\n' in gi
예제 #18
0
def test_tag_activity(gitrepo):
    vcsutils.tag('42.1.0')
    files = [
        ('rever.xsh', REVER_XSH),
    ]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('Some versioned files')
    env_main(['42.1.1'])
    # now see if this worked
    current = vcsutils.latest_tag()
    assert '42.1.1' == current
    # now try to undo the tag
    env_main(['-u', 'tag', '42.1.1'])
    current = vcsutils.latest_tag()
    assert '42.1.0' == current
    # ensure that the updates were commited
    logger = current_logger()
    entries = logger.load()
    assert entries[-2] != entries[-1]
예제 #19
0
def test_conda_forge_activity(gitrepo, gitecho):
    vcsutils.tag('0.0.1')
    env = builtins.__xonsh__.env
    recipe_dir = os.path.join(env['REVER_DIR'], 'rever-feedstock', 'recipe')
    meta_yaml = os.path.join(recipe_dir, 'meta.yaml')
    os.makedirs(recipe_dir, exist_ok=True)
    files = [('rever.xsh', REVER_XSH), (meta_yaml, ORIG_META_YAML),
             ('credfile', CREDFILE)]
    for filename, body in files:
        with open(filename, 'w') as f:
            f.write(body)
    vcsutils.track('.')
    vcsutils.commit('Some versioned files')
    env_main(['0.1.0'])
    # now see if this works
    with open(meta_yaml, 'r') as f:
        obs = f.read()
    assert EXP_META_YAML == obs

    env_main(['0.2.0'])
    # now see if this works
    with open(meta_yaml, 'r') as f:
        obs = f.read()
    assert EXP_META_YAML2 == obs
예제 #20
0
def test_alt_source_rc(gitrepo):
    with open('rc.xsh', 'w') as f:
        f.write('$YOU_DO = "never"\n')
    env_main(args=['--rc=rc.xsh', 'x.y.z'])
    assert builtins.__xonsh__.env['YOU_DO'] == 'never'
    del builtins.__xonsh__.env['YOU_DO']
예제 #21
0
def test_source_rc(gitrepo):
    with open('rever.xsh', 'w') as f:
        f.write('$YOU_DONT = "always"\n')
    env_main(args=['x.y.z'])
    assert builtins.__xonsh__.env['YOU_DONT'] == 'always'
    del builtins.__xonsh__.env['YOU_DONT']