diff options
| author | Trevor Gamblin <tgamblin@baylibre.com> | 2023-09-13 13:00:46 -0400 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-09-14 15:20:08 +0100 |
| commit | 4a6f38c5327b40a45c340af49fee9a0d5cc890bd (patch) | |
| tree | 669ae555ecc031990579baa207d40f38ab7e1335 /meta/lib/patchtest/tests/pyparsing | |
| parent | e12e6d94ecbea6e0dafc080f2f196e12228730eb (diff) | |
| download | poky-4a6f38c5327b40a45c340af49fee9a0d5cc890bd.tar.gz | |
patchtest: Add tests from patchtest oe repo
Copy the core components of the patchtest-oe repo into
meta/lib/patchtest in oe-core.
(From OE-Core rev: 257f64f4e4414b78981104aec132b067beb5a92a)
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/patchtest/tests/pyparsing')
5 files changed, 104 insertions, 0 deletions
diff --git a/meta/lib/patchtest/tests/pyparsing/common.py b/meta/lib/patchtest/tests/pyparsing/common.py new file mode 100644 index 0000000000..9d37b0403d --- /dev/null +++ b/meta/lib/patchtest/tests/pyparsing/common.py | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | # common pyparsing variables | ||
| 2 | # | ||
| 3 | # Copyright (C) 2016 Intel Corporation | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0 | ||
| 6 | |||
| 7 | import pyparsing | ||
| 8 | |||
| 9 | # general | ||
| 10 | colon = pyparsing.Literal(":") | ||
| 11 | start = pyparsing.LineStart() | ||
| 12 | end = pyparsing.LineEnd() | ||
| 13 | at = pyparsing.Literal("@") | ||
| 14 | lessthan = pyparsing.Literal("<") | ||
| 15 | greaterthan = pyparsing.Literal(">") | ||
| 16 | opensquare = pyparsing.Literal("[") | ||
| 17 | closesquare = pyparsing.Literal("]") | ||
| 18 | inappropriate = pyparsing.CaselessLiteral("Inappropriate") | ||
| 19 | submitted = pyparsing.CaselessLiteral("Submitted") | ||
| 20 | |||
| 21 | # word related | ||
| 22 | nestexpr = pyparsing.nestedExpr(opener='[', closer=']') | ||
| 23 | inappropriateinfo = pyparsing.Literal("Inappropriate") + nestexpr | ||
| 24 | submittedinfo = pyparsing.Literal("Submitted") + nestexpr | ||
| 25 | word = pyparsing.Word(pyparsing.alphas) | ||
| 26 | worddot = pyparsing.Word(pyparsing.alphas+".") | ||
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_cve_tags.py b/meta/lib/patchtest/tests/pyparsing/parse_cve_tags.py new file mode 100644 index 0000000000..dd7131a650 --- /dev/null +++ b/meta/lib/patchtest/tests/pyparsing/parse_cve_tags.py | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | # signed-off-by pyparsing definition | ||
| 2 | # | ||
| 3 | # Copyright (C) 2016 Intel Corporation | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0 | ||
| 6 | |||
| 7 | |||
| 8 | import pyparsing | ||
| 9 | import common | ||
| 10 | |||
| 11 | name = pyparsing.Regex('\S+.*(?= <)') | ||
| 12 | username = pyparsing.OneOrMore(common.worddot) | ||
| 13 | domain = pyparsing.OneOrMore(common.worddot) | ||
| 14 | cve = pyparsing.Regex('CVE\-\d{4}\-\d+') | ||
| 15 | cve_mark = pyparsing.Literal("CVE:") | ||
| 16 | |||
| 17 | cve_tag = pyparsing.AtLineStart(cve_mark + cve) | ||
| 18 | patch_cve_tag = pyparsing.AtLineStart("+" + cve_mark + cve) | ||
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_shortlog.py b/meta/lib/patchtest/tests/pyparsing/parse_shortlog.py new file mode 100644 index 0000000000..26e9612c4a --- /dev/null +++ b/meta/lib/patchtest/tests/pyparsing/parse_shortlog.py | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | # subject pyparsing definition | ||
| 2 | # | ||
| 3 | # Copyright (C) 2016 Intel Corporation | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0 | ||
| 6 | |||
| 7 | # NOTE:This is an oversimplified syntax of the mbox's summary | ||
| 8 | |||
| 9 | import pyparsing | ||
| 10 | import common | ||
| 11 | |||
| 12 | target = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables.replace(':',''))) | ||
| 13 | summary = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables)) | ||
| 14 | shortlog = common.start + target + common.colon + summary + common.end | ||
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_signed_off_by.py b/meta/lib/patchtest/tests/pyparsing/parse_signed_off_by.py new file mode 100644 index 0000000000..c8a4351551 --- /dev/null +++ b/meta/lib/patchtest/tests/pyparsing/parse_signed_off_by.py | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | # signed-off-by pyparsing definition | ||
| 2 | # | ||
| 3 | # Copyright (C) 2016 Intel Corporation | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0 | ||
| 6 | |||
| 7 | |||
| 8 | import pyparsing | ||
| 9 | import common | ||
| 10 | |||
| 11 | name = pyparsing.Regex('\S+.*(?= <)') | ||
| 12 | username = pyparsing.OneOrMore(common.worddot) | ||
| 13 | domain = pyparsing.OneOrMore(common.worddot) | ||
| 14 | |||
| 15 | # taken from https://pyparsing-public.wikispaces.com/Helpful+Expressions | ||
| 16 | email = pyparsing.Regex(r"(?P<user>[A-Za-z0-9._%+-]+)@(?P<hostname>[A-Za-z0-9.-]+)\.(?P<domain>[A-Za-z]{2,})") | ||
| 17 | |||
| 18 | email_enclosed = common.lessthan + email + common.greaterthan | ||
| 19 | |||
| 20 | signed_off_by_mark = pyparsing.Literal("Signed-off-by:") | ||
| 21 | signed_off_by = pyparsing.AtLineStart(signed_off_by_mark + name + email_enclosed) | ||
| 22 | patch_signed_off_by = pyparsing.AtLineStart("+" + signed_off_by_mark + name + email_enclosed) | ||
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_upstream_status.py b/meta/lib/patchtest/tests/pyparsing/parse_upstream_status.py new file mode 100644 index 0000000000..511b36d033 --- /dev/null +++ b/meta/lib/patchtest/tests/pyparsing/parse_upstream_status.py | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | # upstream-status pyparsing definition | ||
| 2 | # | ||
| 3 | # Copyright (C) 2016 Intel Corporation | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0 | ||
| 6 | |||
| 7 | |||
| 8 | import common | ||
| 9 | import pyparsing | ||
| 10 | |||
| 11 | upstream_status_literal_valid_status = ["Pending", "Accepted", "Backport", "Denied", "Inappropriate", "Submitted"] | ||
| 12 | upstream_status_nonliteral_valid_status = ["Pending", "Accepted", "Backport", "Denied", "Inappropriate [reason]", "Submitted [where]"] | ||
| 13 | |||
| 14 | upstream_status_valid_status = pyparsing.Or( | ||
| 15 | [pyparsing.Literal(status) for status in upstream_status_literal_valid_status] | ||
| 16 | ) | ||
| 17 | |||
| 18 | upstream_status_mark = pyparsing.Literal("Upstream-Status") | ||
| 19 | inappropriate_status_mark = common.inappropriate | ||
| 20 | submitted_status_mark = common.submitted | ||
| 21 | |||
| 22 | upstream_status = common.start + upstream_status_mark + common.colon + upstream_status_valid_status | ||
| 23 | upstream_status_inappropriate_info = common.start + upstream_status_mark + common.colon + common.inappropriateinfo | ||
| 24 | upstream_status_submitted_info = common.start + upstream_status_mark + common.colon + common.submittedinfo | ||
