diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-08-31 18:41:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-08-31 18:41:59 +0000 |
commit | fe93495fb3728e054d13311bf265e5fc0887f620 (patch) | |
tree | 740c2f2c7d9cda6b41744bbb2a8f11d73b59d374 | |
parent | 9fcdad62c97f8c80eb532699dea21760cf65f7b8 (diff) | |
parent | f00e35ecae062be5bfa4fc9dc8cf4ed3b503bed1 (diff) | |
download | build-fe93495fb3728e054d13311bf265e5fc0887f620.tar.gz |
Merge "If filter/filter_out pattern is a list, remove empty elements from it."
-rw-r--r-- | core/product_config.rbc | 2 | ||||
-rw-r--r-- | tests/run.rbc | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/core/product_config.rbc b/core/product_config.rbc index ef0d0c9f7e..8fbcfa5782 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -439,7 +439,7 @@ def __mk2regex(words): """Returns regular expression equivalent to Make pattern.""" # TODO(asmundak): this will mishandle '\%' - return "^(" + "|".join([w.replace("%", ".*", 1) for w in words]) + ")" + return "^(" + "|".join([w.replace("%", ".*", 1) for w in words if w]) + ")$" def _regex_match(regex, w): return rblf_regex(regex, w) diff --git a/tests/run.rbc b/tests/run.rbc index 4d7166a29a..2c15b8105c 100644 --- a/tests/run.rbc +++ b/tests/run.rbc @@ -47,6 +47,9 @@ assert_eq(["%/foo"], rblf.mkpatsubst("%", "\\%/%", ["foo"])) assert_eq(["foo/%"], rblf.mkpatsubst("%", "%/%", ["foo"])) assert_eq(["from/a:to/a", "from/b:to/b"], rblf.product_copy_files_by_pattern("from/%", "to/%", "a b")) +assert_eq([], rblf.filter(["a", "", "b"], "f")) +assert_eq(["", "b"], rblf.filter_out(["a", "" ], ["a", "", "b"] )) + globals, config = rblf.product_configuration("test/device", init) assert_eq( { |