From 20b324201ecfcf7fcd3c0d923f8c388057ece54b Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Mon, 9 Sep 2013 14:03:06 -0400 Subject: [PATCH] Fixed bug in directory field wildcard expansion (h/t StiX) --- src/base/api.lua | 2 +- tests/api/test_directory_kind.lua | 47 +++++++++++++++++++++++++++++++ tests/premake4.lua | 1 + 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/api/test_directory_kind.lua diff --git a/src/base/api.lua b/src/base/api.lua index 843878c8..74a5c0a4 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -383,7 +383,7 @@ if value:find("*") then local values = os.matchdirs(value) table.foreachi(values, function(v) - api.setdirectory(target, name, field, values[i]) + api.setdirectory(target, name, field, v) name = name + 1 end) else diff --git a/tests/api/test_directory_kind.lua b/tests/api/test_directory_kind.lua new file mode 100644 index 00000000..6ee25702 --- /dev/null +++ b/tests/api/test_directory_kind.lua @@ -0,0 +1,47 @@ +-- +-- tests/api/test_directory_kind.lua +-- Tests the directory API value type. +-- Copyright (c) 2013 Jason Perkins and the Premake project +-- + + local suite = test.declare("api_directory_kind") + local api = premake.api + + +-- +-- Setup and teardown +-- + + function suite.setup() + api.register { + name = "testapi", + kind = "directory-list", + scope = "project" + } + test.createsolution() + 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 "./*" + test.istrue(table.contains(api.scope.project.testapi, os.getcwd() .. "/api")) + end diff --git a/tests/premake4.lua b/tests/premake4.lua index a2acd0b9..46e1918b 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -75,6 +75,7 @@ dofile("api/test_array_kind.lua") dofile("api/test_callback.lua") dofile("api/test_containers.lua") + dofile("api/test_directory_kind.lua") dofile("api/test_list_kind.lua") dofile("api/test_path_kind.lua") dofile("api/test_register.lua")