1import pytest 2import checkpackagelib.test_util as util 3import checkpackagelib.lib_patch as m 4 5 6ApplyOrder = [ 7 ('standard', # catches https://bugs.busybox.net/show_bug.cgi?id=11271 8 '0001-description.patch', 9 '', 10 []), 11 ('standard with path', 12 'path/0001-description.patch', 13 '', 14 []), 15 ('acceptable format', 16 '1-description.patch', 17 '', 18 []), 19 ('acceptable format with path', 20 'path/1-description.patch', 21 '', 22 []), 23 ('old format', 24 'package-0001-description.patch', 25 '', 26 [['package-0001-description.patch:0: use name <number>-<description>.patch (url#_providing_patches)']]), 27 ('old format with path', 28 'path/package-0001-description.patch', 29 '', 30 [['path/package-0001-description.patch:0: use name <number>-<description>.patch (url#_providing_patches)']]), 31 ('missing number', 32 'description.patch', 33 '', 34 [['description.patch:0: use name <number>-<description>.patch (url#_providing_patches)']]), 35 ('missing number with path', 36 'path/description.patch', 37 '', 38 [['path/description.patch:0: use name <number>-<description>.patch (url#_providing_patches)']]), 39 ] 40 41 42@pytest.mark.parametrize('testname,filename,string,expected', ApplyOrder) 43def test_ApplyOrder(testname, filename, string, expected): 44 warnings = util.check_file(m.ApplyOrder, filename, string) 45 assert warnings == expected 46 47 48NumberedSubject = [ 49 ('no subject', 50 'patch', 51 '', 52 []), 53 ('acceptable because it is not a git patch', 54 'patch', 55 'Subject: [PATCH 24/105] text\n', 56 []), 57 ('good', 58 'patch', 59 'Subject: [PATCH] text\n' 60 'diff --git a/configure.ac b/configure.ac\n', 61 []), 62 ('bad', 63 'patch', 64 'Subject: [PATCH 24/105] text\n' 65 'diff --git a/configure.ac b/configure.ac\n', 66 [["patch:1: generate your patches with 'git format-patch -N'", 67 'Subject: [PATCH 24/105] text\n']]), 68 ] 69 70 71@pytest.mark.parametrize('testname,filename,string,expected', NumberedSubject) 72def test_NumberedSubject(testname, filename, string, expected): 73 warnings = util.check_file(m.NumberedSubject, filename, string) 74 assert warnings == expected 75 76 77Sob = [ 78 ('good', 79 'patch', 80 'Signed-off-by: John Doe <johndoe@example.com>\n', 81 []), 82 ('empty', 83 'patch', 84 '', 85 [['patch:0: missing Signed-off-by in the header (url#_format_and_licensing_of_the_package_patches)']]), 86 ('bad', 87 'patch', 88 'Subject: [PATCH 24/105] text\n', 89 [['patch:0: missing Signed-off-by in the header (url#_format_and_licensing_of_the_package_patches)']]), 90 ] 91 92 93@pytest.mark.parametrize('testname,filename,string,expected', Sob) 94def test_Sob(testname, filename, string, expected): 95 warnings = util.check_file(m.Sob, filename, string) 96 assert warnings == expected 97 98 99Upstream = [ 100 ('good', 101 'patch', 102 'Upstream: https://some/amazing/patch/submission\n', 103 []), 104 ('empty', 105 'patch', 106 '', 107 [['patch:0: missing Upstream in the header (url#_additional_patch_documentation)']]), 108 ('bad', 109 'patch', 110 'Subject: [PATCH 24/105] text\n', 111 [['patch:0: missing Upstream in the header (url#_additional_patch_documentation)']]), 112 ] 113 114 115@pytest.mark.parametrize('testname,filename,string,expected', Upstream) 116def test_Upstream(testname, filename, string, expected): 117 warnings = util.check_file(m.Upstream, filename, string) 118 assert warnings == expected 119