def test_set_commit_ref_macro(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'commit') with dist_path.as_cwd(): spec = specfile.Spec() spec.set_commit_ref_macro('86a713c35718520cb3b681260182a8388ac809f3') spec.save() common.assert_distgit(dist_path, 'commit-patched')
def test_update_dense_ex(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'empty-dense-ex') with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches(extra=True) update_patches('master', local_patches_branch='master-patches', version='1.2.3') common.assert_distgit(dist_path, 'patched-dense-ex')
def test_update_comments(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'some-comments') with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches(extra=True) update_patches('master', local_patches_branch='master-patches', version='1.2.3') common.assert_distgit(dist_path, 'patched-comments')
def test_update_double_patches_base(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'double-patches') with dist_path.as_cwd(): common.prep_patches_branch() with pytest.raises(rdopkg.exception.DuplicatePatchesBaseError): update_patches('master', local_patches_branch='master-patches', version='1.2.3') common.assert_distgit(dist_path, 'double-patches')
def test_update_double_patches_base(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'double-patches') with dist_path.as_cwd(): common.prep_patches_branch() with pytest.raises(rdopkg.exception.LintProblemsFound): update_patches('master', local_patches_branch='master-patches', version='1.2.3') common.assert_distgit(dist_path, 'double-patches')
def test_patches_base_noop_weird(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'empty-weird') with dist_path.as_cwd(): spec = specfile.Spec() ver, np = spec.get_patches_base() assert ver == 'banana' assert np == 2 spec.set_patches_base_version('banana') spec.save() common.assert_distgit(dist_path, 'empty-weird')
def test_patches_base_add_empty(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'empty') with dist_path.as_cwd(): spec = specfile.Spec() ver, np = spec.get_patches_base() assert ver is None assert np == 0 spec.set_patches_base_version('+2') spec.save() common.assert_distgit(dist_path, 'empty-ex')
def test_new_version_patches_base_ignore_new_version(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'magic-comments') with dist_path.as_cwd(): spec2 = specfile.Spec() spec2.set_tag('Version', '1.2.4') spec2.set_release('1') spec2.set_patches_base_version(None) spec2.save() spec2 = None spec = specfile.Spec() assert spec.get_patches_ignore_regex().pattern == 'DROP-IN-RPM'
def test_update_autosetup(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'autosetup') with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches(extra=True) update_patches('master', local_patches_branch='master-patches', version='1.2.3') apply_method = specfile.Spec().patches_apply_method() assert apply_method == 'autosetup' common.assert_distgit(dist_path, 'patched-autosetup')
def test_update_git_am_buildarch_fail(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'git-am-fail') with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches(extra=True) with pytest.raises(rdopkg.exception.BuildArchSanityCheckFailed): update_patches('master', local_patches_branch='master-patches', version='1.2.3') apply_method = specfile.Spec().patches_apply_method() assert apply_method == 'git-am'
def test_update_git_am_buildarch_fail(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'git-am-fail') with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches(extra=True) with pytest.raises(rdopkg.exception.LintProblemsFound): update_patches('master', local_patches_branch='master-patches', version='1.2.3') apply_method = specfile.Spec().patches_apply_method() assert apply_method == 'git-am'
def test_get_magic_comment(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'patched-filter') with dist_path.as_cwd(): spec = specfile.Spec() def _assert_mc(name, exp_val): spec_val = spec.get_magic_comment(name) assert spec_val == exp_val _assert_mc('patches_base', '+2') _assert_mc('patches_ignore', 'DROP-IN-RPM') _assert_mc('not_really_there', None) _assert_mc('¯\_(ツ)_/¯', None)
def test_patch_add(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'patched') with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches() commit_before = git('rev-parse', 'HEAD') common.add_n_patches(3) rdopkg('patch', '-l') commit_after = git('rev-parse', 'HEAD') git_clean = git.is_clean() common.norm_changelog() common.assert_distgit(dist_path, 'patch-add') assert commit_before != commit_after, "New commit not created" assert git_clean, "git not clean after action"
def _test_patch_noop(tmpdir, distgit, cmd): dist_path = common.prep_spec_test(tmpdir, distgit) with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches() # regen patch files in order for hashes to match git rdopkg('update-patches', '--amend') commit_before = git('rev-parse', 'HEAD') rdopkg(*cmd) commit_after = git('rev-parse', 'HEAD') git_clean = git.is_clean() common.assert_distgit(dist_path, distgit) assert commit_before == commit_after, "New commit created for noop" assert git_clean, "git not clean after action"
def _test_patch_regen(tmpdir, distgit, distgit_after, cmd, norm_changelog=True): dist_path = common.prep_spec_test(tmpdir, distgit) with dist_path.as_cwd(): common.prep_patches_branch() common.add_patches() commit_before = git('rev-parse', 'HEAD') rdopkg(*cmd) commit_after = git('rev-parse', 'HEAD') git_clean = git.is_clean() if norm_changelog: common.norm_changelog() common.assert_distgit(dist_path, distgit_after) assert commit_before != commit_after, \ "New commit not created after patch regen" assert git_clean, "git not clean after action"
def _test_new_version(asset, dir, steps): dist_path = common.prep_spec_test(dir, asset) log.log.setLevel(log.WARN) with dist_path.as_cwd(): common.prep_patches_branch() for new_version, spec_version, spec_release_parts, spec_milestone \ in steps: commit_before = git('rev-parse', 'HEAD') common.add_patches(tag=new_version) rdopkg('new-version', '-l', '-d', new_version) # after commit_after = git('rev-parse', 'HEAD') common.assert_spec_version(spec_version, spec_release_parts, spec_milestone) assert commit_before != commit_after
def test_update_noop(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'patched') spec_path = dist_path.join('foo.spec') with dist_path.as_cwd(): common.prep_patches_branch() spec_before = spec_path.read() common.add_patches() update_patches('master', local_patches_branch='master-patches', version='1.2.3') spec_after = spec_path.read() assert spec_after == spec_before spec_before = spec_after update_patches('master', local_patches_branch='master-patches', version='1.2.3') spec_after = spec_path.read() assert spec_after == spec_before
def _test_patch(asset, version, dir): dist_path = common.prep_spec_test(dir, asset) log.log.setLevel(log.WARN) with dist_path.as_cwd(): spec_version, spec_release_parts, spec_milestone = version tag = spec_version if spec_milestone: tag += spec_milestone common.prep_patches_branch(tag=tag) commit_before = git('rev-parse', 'HEAD') common.add_patches() rdopkg('patch', '-l') # after commit_after = git('rev-parse', 'HEAD') common.assert_spec_version(spec_version, spec_release_parts, spec_milestone) assert commit_before != commit_after, "No commit created" prev = git('rev-parse', 'HEAD~') assert prev == commit_before, "Multiple commits created"
def test_new_version_patches_base_ignore_load(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'magic-comments') with dist_path.as_cwd(): spec = specfile.Spec() assert spec.get_patches_ignore_regex().pattern == 'DROP-IN-RPM' assert spec.get_patches_base() == ('1.2.3', 0)
def test_get_patches_ignore_regex(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'empty-ex-filter') with dist_path.as_cwd(): spec = specfile.Spec() regex = spec.get_patches_ignore_regex() assert regex.pattern == 'DROP-IN-RPM'
def test_get_patches_ignore_regex_fail(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'empty-filter-bogus') with dist_path.as_cwd(): spec = specfile.Spec() regex = spec.get_patches_ignore_regex() assert regex is None
def test_new_version_patches_base_ignore_mangling_minimal_2(tmpdir): dist_path = common.prep_spec_test(tmpdir, 'patched-filter') with dist_path.as_cwd(): spec = specfile.Spec() spec.set_patches_base_version(None) assert spec.get_patches_ignore_regex().pattern == 'DROP-IN-RPM'