def test_help_rm_help(git_project_runner, git): workdir = git.get_working_copy_root() git_project_runner.chdir(workdir) git_project_runner.run('.*', '', 'add', 'help', 'foo', 'Test help') check_config_file('project.help.foo', 'short', {'Test help'}) git_project_runner.run('.*', '', 'add', 'help', '--manpage', 'foo', 'Manpage help') check_config_file('project.help.foo', 'manpage', {'Manpage help'}) git_project_runner.run('.*', '', 'rm', 'help', 'foo') check_config_file('project.help.foo', 'short', {'Test help'}, key_present=False) check_config_file('project.help.foo', 'manpage', {'Manpage help'}) git_project_runner.run('.*', '', 'rm', 'help', '--manpage', 'foo') check_config_file('project.help.foo', 'manpage', {}, section_present=False, key_present=False)
def test_run_substitute_alias(git_project_runner, git, capsys): workdir = git.get_working_copy_root() git_project_runner.chdir(workdir) # Add aliases. git_project_runner.run('.*', '', 'run', '--make-alias', 'build') git_project_runner.run('.*', '', 'run', '--make-alias', 'check') check_config_file('project.run', 'alias', {'build', 'check'}) # Add a build. git_project_runner.run('.*', '', 'add', 'build', 'test', '{path}/buildit {branch} {build}') # Add a check. git_project_runner.run('.*', '', 'add', 'check', 'test', '{path}/checkit {build}') # Check build invocation. git_project_runner.run(re.escape(f'{workdir}/buildit master test'), '.*', 'build', 'test') # Check check invocation. git_project_runner.run(re.escape(f'{workdir}/checkit test'), '.*', 'check', 'test')
def test_artifact_add(git_project_runner, git): workdir = git.get_working_copy_root() git_project_runner.chdir(workdir) git_project_runner.run('.*', '', 'artifact', 'add', 'worktree', '{builddir}') check_config_file('project.artifact.worktree', 'path', {'{builddir}'})
def test_help_and_help(git_project_runner, git): workdir = git.get_working_copy_root() git_project_runner.chdir(workdir) git_project_runner.run('.*', '', 'add', 'help', 'foo', 'Test help') check_config_file('project.help.foo', 'short', {'Test help'}) git_project_runner.run('.*', '', 'add', 'help', '--manpage', 'foo', 'Manpage help') check_config_file('project.help.foo', 'manpage', {'Manpage help'})
def test_shell_add(reset_directory, git_project_runner, git): workdir = git.get_working_copy_root() git_project_runner.chdir(workdir) git_project_runner.run('.*', '', 'config', 'builddir', '{path}/{branch}') git_project_runner.run('.*', '', 'config', 'flavor', 'devrel') git_project_runner.run('.*', '', 'config', '--add', 'flavor', 'check-devrel') os.chdir(git._repo.path) check_config_file('project', 'builddir', {'{path}/{branch}'}) check_config_file('project', 'flavor', {'devrel', 'check-devrel'})
def test_artifact_rm_items(git_project_runner, git): workdir = git.get_working_copy_root() git_project_runner.chdir(workdir) git_project_runner.run('.*', '', 'artifact', 'add', 'worktree', '{builddir}') git_project_runner.run('.*', '', 'artifact', 'add', 'worktree', '{installdir}') check_config_file('project.artifact.worktree', 'path', {'{builddir}', '{installdir}'}) git_project_runner.run('.*', '', 'artifact', 'rm', 'worktree') check_config_file('project.artifact.worktree', 'path', {'{builddir}, ' '{installdir}'}, section_present=False)
def test_run_no_dup(reset_directory, git_project_runner, git): workdir = git.get_working_copy_root() git_project_runner.chdir(workdir) git_project_runner.run('.*', '', 'config', 'rundir', '{path}/{branch}') git_project_runner.run('.*', '', 'add', 'run', 'devrel', '{rundir}/doit {branch}') git_project_runner.run('.*', '', 'add', 'run', 'check-devrel', '{rundir}/check-doit {branch}') os.chdir(git._repo.path) check_config_file('project', 'run', {'devrel', 'check-devrel'}) git_project_runner.run(re.escape(f'{workdir}/master/doit master'), '.*', 'run', 'devrel') check_config_file('project', 'run', {'devrel', 'check-devrel'}) git_project_runner.run(re.escape(f'{workdir}/master/check-doit master'), '.*', 'run', 'check-devrel') check_config_file('project', 'run', {'devrel', 'check-devrel'})
def test_main_no_dup(reset_directory, git, project): project._git.validate_config() project._git.validate_config() git_project.main_impl(['config', 'branch']) project.build = 'devrel' project._git.validate_config() git_project.main_impl(['config', 'branch']) project.add_item('build', 'check-devrel') project._git.validate_config() git_project.main_impl(['config', 'branch']) check_config_file('project', 'build', {'devrel', 'check-devrel'}) project._git.validate_config() git_project.main_impl(['config', 'branch']) check_config_file('project', 'build', {'devrel', 'check-devrel'})
def test_confobj_get_no_dup(reset_directory, git): thing = MyThing.get(git, 'project', 'test') thing.first = 'firstdefault' thing.second = 'seconddefault' thing.add_item('second', 'secondsecond') thing.add_item('second', 'secondthird') newthing = MyThing.get(git, 'project', 'test') check_config_file('project.mything.test', 'first', {'firstdefault'}) check_config_file('project.mything.test', 'second', {'seconddefault', 'secondsecond', 'secondthird'}) os.chdir(git._repo.path) newgit = git_project.Git() check_config_file('project.mything.test', 'first', {'firstdefault'}) check_config_file('project.mything.test', 'second', {'seconddefault', 'secondsecond', 'secondthird'})
def test_runnable_substitute_command_no_dup(reset_directory, git): class MyProject(git_project.ScopedConfigObject): def __init__(self): super().__init__(git, 'project', None, 'myproject', builddir='/path/to/build/{target}', target='install') runnable = MyRunnable.get(git, 'project', 'test') project = MyProject() project.build = 'devrel' project.add_item('build', 'check-devrel') check_config_file('project.myproject', 'builddir', {'/path/to/build/{target}'}) check_config_file('project.myproject', 'target', {'install'}) check_config_file('project.myproject', 'build', {'devrel', 'check-devrel'}) command = runnable.substitute_command(git, project) assert command == f'cd /path/to/build/{project.target}/{git.get_current_branch()} && make {project.target}' check_config_file('project.myproject', 'builddir', {'/path/to/build/{target}'}) check_config_file('project.myproject', 'target', {'install'}) check_config_file('project.myproject', 'build', {'devrel', 'check-devrel'})
def test_runnable_run_no_dup(reset_directory, git): class MyProject(git_project.ScopedConfigObject): def __init__(self): super().__init__(git, 'project', None, 'myproject', builddir='/path/to/build/{target}', target='install') runnable = MyRunnable.get(git, 'project', 'test') project = MyProject() project.build = 'devrel' project.add_item('build', 'check-devrel') check_config_file('project.myproject', 'builddir', {'/path/to/build/{target}'}) check_config_file('project.myproject', 'target', {'install'}) check_config_file('project.myproject', 'build', {'devrel', 'check-devrel'}) clargs = dict() runnable.run(git, project, clargs) check_config_file('project.myproject', 'builddir', {'/path/to/build/{target}'}) check_config_file('project.myproject', 'target', {'install'}) check_config_file('project.myproject', 'build', {'devrel', 'check-devrel'})