Added support & tests for XCTest sharedlibtype

This commit is contained in:
Ross Brackstone 2019-01-09 14:12:44 +10:00
parent ffc1596a23
commit c0ceb0f26d
6 changed files with 74 additions and 0 deletions

View File

@ -215,6 +215,30 @@
]] ]]
end end
function suite.PBXFileReference_ListsXCTestTarget()
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject.xctest:product] /* MyProject.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = MyProject.xctest; path = MyProject.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_ListsIOSXCTestTarget()
_TARGET_OS = "ios"
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject.xctest:product] /* MyProject.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = MyProject.xctest; path = MyProject.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_ListsOSXFrameworkTarget() function suite.PBXFileReference_ListsOSXFrameworkTarget()
kind "SharedLib" kind "SharedLib"
@ -1294,6 +1318,26 @@
]] ]]
end end
function suite.XCBuildConfigurationTarget_OnXCTest()
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[MyProject.xctest:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_DYNAMIC_NO_PIC = NO;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationTarget_OnOSXFramework() function suite.XCBuildConfigurationTarget_OnOSXFramework()
kind "SharedLib" kind "SharedLib"

View File

@ -268,6 +268,7 @@
SharedLib = "com.apple.product-type.library.dynamic", SharedLib = "com.apple.product-type.library.dynamic",
OSXBundle = "com.apple.product-type.bundle", OSXBundle = "com.apple.product-type.bundle",
OSXFramework = "com.apple.product-type.framework", OSXFramework = "com.apple.product-type.framework",
XCTest = "com.apple.product-type.bundle.unit-test",
} }
return types[iif(node.cfg.kind == "SharedLib" and node.cfg.sharedlibtype, node.cfg.sharedlibtype, node.cfg.kind)] return types[iif(node.cfg.kind == "SharedLib" and node.cfg.sharedlibtype, node.cfg.sharedlibtype, node.cfg.kind)]
end end
@ -290,6 +291,7 @@
SharedLib = "\"compiled.mach-o.dylib\"", SharedLib = "\"compiled.mach-o.dylib\"",
OSXBundle = "wrapper.cfbundle", OSXBundle = "wrapper.cfbundle",
OSXFramework = "wrapper.framework", OSXFramework = "wrapper.framework",
XCTest = "wrapper.cfbundle",
} }
return types[iif(node.cfg.kind == "SharedLib" and node.cfg.sharedlibtype, node.cfg.sharedlibtype, node.cfg.kind)] return types[iif(node.cfg.kind == "SharedLib" and node.cfg.sharedlibtype, node.cfg.sharedlibtype, node.cfg.kind)]
end end
@ -1125,6 +1127,7 @@
StaticLib = "a", StaticLib = "a",
OSXBundle = "bundle", OSXBundle = "bundle",
OSXFramework = "framework", OSXFramework = "framework",
XCTest = "xctest",
} }
local ext = cfg.buildtarget.extension:sub(2) local ext = cfg.buildtarget.extension:sub(2)
if ext ~= exts[iif(cfg.kind == "SharedLib" and cfg.sharedlibtype, cfg.sharedlibtype, cfg.kind)] then if ext ~= exts[iif(cfg.kind == "SharedLib" and cfg.sharedlibtype, cfg.sharedlibtype, cfg.kind)] then

View File

@ -708,6 +708,7 @@
allowed = { allowed = {
"OSXBundle", "OSXBundle",
"OSXFramework", "OSXFramework",
"XCTest",
}, },
} }
@ -1778,6 +1779,10 @@
targetprefix "" targetprefix ""
targetextension ".framework" targetextension ".framework"
filter { "system:darwin", "kind:SharedLib", "sharedlibtype:XCTest" }
targetprefix ""
targetextension ".xctest"
-- Windows and friends. -- Windows and friends.
filter { "system:Windows or language:C# or language:F#", "kind:ConsoleApp or WindowedApp" } filter { "system:Windows or language:C# or language:F#", "kind:ConsoleApp or WindowedApp" }

View File

@ -306,6 +306,8 @@
if table.contains(os.getSystemTags(cfg.system), "darwin") then if table.contains(os.getSystemTags(cfg.system), "darwin") then
if cfg.sharedlibtype == "OSXBundle" then if cfg.sharedlibtype == "OSXBundle" then
return "-bundle" return "-bundle"
elseif cfg.sharedlibtype == "XCTest" then
return "-bundle"
elseif cfg.sharedlibtype == "OSXFramework" then elseif cfg.sharedlibtype == "OSXFramework" then
return "-framework" return "-framework"
else else

View File

@ -231,6 +231,18 @@
test.isequal("bin/Debug/MyProject.bundle/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath)) test.isequal("bin/Debug/MyProject.bundle/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
end end
--
-- Bundle path should be set for macOS/iOS cocoa unit test bundle.
--
function suite.bundlepathSet_onMacSharedLibXCTest()
kind "SharedLib"
sharedlibtype "XCTest"
system "macosx"
i = prepare()
test.isequal("bin/Debug/MyProject.xctest/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
end
-- --
-- Bundle path should be set for macOS/iOS framework. -- Bundle path should be set for macOS/iOS framework.

View File

@ -353,6 +353,14 @@
test.contains({ "-Wl,-x", "-bundle" }, gcc.getldflags(cfg)) test.contains({ "-Wl,-x", "-bundle" }, gcc.getldflags(cfg))
end end
function suite.ldflags_onMacOSXXCTest()
system "MacOSX"
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
test.contains({ "-Wl,-x", "-bundle" }, gcc.getldflags(cfg))
end
function suite.ldflags_onMacOSXFramework() function suite.ldflags_onMacOSXFramework()
system "MacOSX" system "MacOSX"
kind "SharedLib" kind "SharedLib"