From fee075fba76c3900190305845e25190209929a17 Mon Sep 17 00:00:00 2001 From: Joris Dauphin Date: Tue, 31 Oct 2023 06:29:24 +0100 Subject: [PATCH] Allow to use wildcard for `buildinputs`. (#2150) * Allow to use wildcard for `buildinputs`. * Add UTs for `kind = "file"` for `api.register` --- src/_premake_init.lua | 2 +- tests/_tests.lua | 1 + tests/api/test_file_kind.lua | 47 ++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/api/test_file_kind.lua diff --git a/src/_premake_init.lua b/src/_premake_init.lua index e072ed121e..88d6090bc4 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -117,7 +117,7 @@ api.register { name = "buildinputs", scope = "config", - kind = "list:path", + kind = "list:file", tokens = true, pathVars = false, } diff --git a/tests/_tests.lua b/tests/_tests.lua index 34ec6f69de..80e2e07687 100644 --- a/tests/_tests.lua +++ b/tests/_tests.lua @@ -48,6 +48,7 @@ return { "api/test_boolean_kind.lua", "api/test_containers.lua", "api/test_directory_kind.lua", + "api/test_file_kind.lua", "api/test_list_kind.lua", "api/test_path_kind.lua", "api/test_register.lua", diff --git a/tests/api/test_file_kind.lua b/tests/api/test_file_kind.lua new file mode 100644 index 0000000000..a9c2a9bc7f --- /dev/null +++ b/tests/api/test_file_kind.lua @@ -0,0 +1,47 @@ +-- +-- tests/api/test_file_kind.lua +-- Tests the file API value type. +-- Copyright (c) 2023 the Premake project +-- + +local p = premake +local suite = test.declare("api_file_kind") +local api = p.api + +-- +-- Setup and teardown +-- + +function suite.setup() + api.register { + name = "testapi", + kind = "file", + list = true, + scope = "project" + } + test.createWorkspace() +end + +function suite.teardown() + testapi = nil +end + +-- +-- Values should be converted to absolute paths, +-- relative to the currently running script. +-- +function suite.convertsToAbsolute() + testapi "self/local" + + test.isequal({os.getcwd() .. "/self/local"}, api.scope.project.testapi) +end + + +-- +-- Check expansion of wildcards. +-- +function suite.expandsWildcards() + testapi (_TESTS_DIR .. "/api/*") + + test.istrue(table.contains(api.scope.project.testapi, _TESTS_DIR .. "/api/test_file_kind.lua")) +end