summaryrefslogtreecommitdiff
path: root/tests/modules/private/select_script/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-05 00:52:03 +0800
committerruki <[email protected]>2024-03-05 00:52:03 +0800
commit69d11ecb1f292694bec66c061ad4c92584e9f7d5 (patch)
tree728939f063f0c11e35b132940383eae0657a3e65 /tests/modules/private/select_script/test.lua
parent4ff48f7a7027ab9c403f2448c918d2d1ded118fa (diff)
improve to select script
Diffstat (limited to 'tests/modules/private/select_script/test.lua')
-rw-r--r--tests/modules/private/select_script/test.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/modules/private/select_script/test.lua b/tests/modules/private/select_script/test.lua
index 193da790a..f1e950dd1 100644
--- a/tests/modules/private/select_script/test.lua
+++ b/tests/modules/private/select_script/test.lua
@@ -1,6 +1,23 @@
import("private.core.base.select_script")
+function _match_pattern(pattern, opt)
+ pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
+ pattern = pattern:gsub("%*", "\001")
+ pattern = pattern:gsub("\001", ".*")
+ return select_script({[pattern] = true}, opt) == true
+end
+
function test_plat_only(t)
+ t:require(_match_pattern("*", {plat = "macosx"}))
+ t:require(_match_pattern("macosx", {plat = "macosx"}))
+ t:require(_match_pattern("macosx,linux", {plat = "macosx"}))
+ t:require(_match_pattern("mac*", {plat = "macosx"}))
+ t:require_not(_match_pattern("macosx", {plat = "linux"}))
+ t:require_not(_match_pattern("linux", {plat = "macosx"}))
+ t:require_not(_match_pattern("!macosx", {plat = "macosx"}))
+ t:require_not(_match_pattern("!mac*", {plat = "macosx"}))
+ t:require(_match_pattern("!macosx", {plat = "linux"}))
+ t:require(_match_pattern("!mac*", {plat = "linux"}))
end
function test_arch_only(t)