This repository has been archived on 2022-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
fuck-premake-old2/tests/actions/test_xcode.lua

442 lines
12 KiB
Lua
Raw Normal View History

--
-- tests/actions/test_xcode.lua
-- Automated test suite for the "clean" action.
-- Copyright (c) 2009 Jason Perkins and the Premake project
--
T.xcode3 = { }
local xcode = premake.xcode
2009-09-03 18:11:41 +00:00
--
-- Replacement for xcode.newid(). This one creates a synthetic ID based on the node name,
-- it's intended usage (file ID, build ID, etc.) and it's place in the tree. This makes
-- it easier to tell if the right ID is being used in the right places.
--
local used_ids = {}
local function newtestableid(node, usage)
if not usage and #node.children == 0 then
if node.languages then
usage = "group"
elseif not node.stageid then
usage = "file"
end
end
local name = node.name
if usage then
name = name .. ":" .. usage
end
if used_ids[name] then
local count = used_ids[name] + 1
used_ids[name] = count
name = name .. "(" .. count .. ")"
else
used_ids[name] = 1
end
return "[" .. name .. "]"
end
--
-- Configure a solution for testing
--
local sln, old_newid
function T.xcode3.setup()
_ACTION = 'xcode3'
2009-09-03 18:11:41 +00:00
old_newid = xcode.newid
xcode.newid = newtestableid
used_ids = { }
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms {}
prj = project "MyProject"
language "C++"
kind "ConsoleApp"
end
2009-09-03 18:11:41 +00:00
function T.xcode3.teardown()
xcode.newid = old_newid
end
2009-09-03 18:11:41 +00:00
2009-08-24 00:47:21 +00:00
local ctx
local function prepare()
io.capture()
premake.buildconfigs()
2009-08-24 00:47:21 +00:00
ctx = xcode.buildcontext(sln)
end
2009-09-03 18:11:41 +00:00
local function project2()
project "MyProject2"
language "C++"
kind "ConsoleApp"
end
--
-- File header/footer tests
--
function T.xcode3.Header()
prepare()
xcode.header()
test.capture [[
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objects = {
]]
end
function T.xcode3.Footer()
prepare()
xcode.footer()
test.capture [[
};
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
}
]]
end
--
-- PBXBuildFile section tests
--
function T.xcode3.PBXBuildFile_ListsBuildableSources()
files {
2009-09-02 22:18:49 +00:00
"source.h", "source.c", "source.cpp", "Info.plist",
}
prepare()
2009-08-24 00:47:21 +00:00
xcode.PBXBuildFile(ctx)
test.capture [[
/* Begin PBXBuildFile section */
2009-09-03 18:11:41 +00:00
[source.c:build] /* source.c in Sources */ = {isa = PBXBuildFile; fileRef = [source.c:file] /* source.c */; };
[source.cpp:build] /* source.cpp in Sources */ = {isa = PBXBuildFile; fileRef = [source.cpp:file] /* source.cpp */; };
/* End PBXBuildFile section */
]]
end
2009-08-24 00:47:21 +00:00
function T.xcode3.PBXBuildFile_ListsResourceFilesOnlyOnceWithGroupID()
2009-08-24 21:42:14 +00:00
files {
2009-08-26 20:42:27 +00:00
"English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib"
2009-08-24 21:42:14 +00:00
}
prepare()
xcode.PBXBuildFile(ctx)
test.capture [[
/* Begin PBXBuildFile section */
2009-09-03 18:11:41 +00:00
[MainMenu.xib:build] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib:group] /* MainMenu.xib */; };
/* End PBXBuildFile section */
]]
end
function T.xcode3.PBXBuildFile_SeparatesResourcesByProject()
files { "MyProject/English.lproj/MainMenu.xib", "MyProject/French.lproj/MainMenu.xib" }
project2()
files { "MyProject2/English.lproj/MainMenu.xib", "MyProject2/French.lproj/MainMenu.xib" }
prepare()
xcode.PBXBuildFile(ctx)
test.capture [[
/* Begin PBXBuildFile section */
2009-09-03 18:11:41 +00:00
[MainMenu.xib:build] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib:group] /* MainMenu.xib */; };
[MainMenu.xib:build(2)] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib:group(2)] /* MainMenu.xib */; };
/* End PBXBuildFile section */
]]
end
function T.xcode3.PBXBuildFile_ListsFrameworks()
links { "Cocoa.framework" }
prepare()
xcode.PBXBuildFile(ctx)
test.capture [[
/* Begin PBXBuildFile section */
2009-09-03 18:11:41 +00:00
[Cocoa.framework:build] /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = [Cocoa.framework:file] /* Cocoa.framework */; };
/* End PBXBuildFile section */
]]
end
2009-08-24 00:47:21 +00:00
--
-- PBXFileReference section tests
--
2009-09-02 22:18:49 +00:00
function T.xcode3.PBXFileReference_ListsConsoleTarget()
prepare()
xcode.PBXFileReference(ctx)
test.capture [[
/* Begin PBXFileReference section */
2009-09-03 18:11:41 +00:00
[MyProject:file] /* MyProject */ = {isa = PBXFileReference; explicitFileType = compiled.mach-o.executable; includeInIndex = 0; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
2009-09-02 22:18:49 +00:00
function T.xcode3.PBXFileReference_ListsWindowedTarget()
kind "WindowedApp"
prepare()
xcode.PBXFileReference(ctx)
test.capture [[
/* Begin PBXFileReference section */
2009-09-03 18:11:41 +00:00
[MyProject.app:file] /* MyProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MyProject.app; sourceTree = BUILT_PRODUCTS_DIR; };
2009-09-02 22:18:49 +00:00
/* End PBXFileReference section */
]]
end
2009-08-24 21:42:14 +00:00
function T.xcode3.PBXFileReference_ListSourceTypesCorrectly()
2009-08-24 00:47:21 +00:00
files {
"source.h", "source.c", "source.cpp"
2009-08-24 00:47:21 +00:00
}
prepare()
xcode.PBXFileReference(ctx)
test.capture [[
/* Begin PBXFileReference section */
2009-09-03 18:11:41 +00:00
[source.h:file] /* source.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = source.h; path = source.h; sourceTree = "<group>"; };
[source.c:file] /* source.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = source.c; path = source.c; sourceTree = "<group>"; };
[source.cpp:file] /* source.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = source.cpp; path = source.cpp; sourceTree = "<group>"; };
2009-08-24 00:47:21 +00:00
]]
end
2009-08-24 21:42:14 +00:00
2009-08-24 21:42:14 +00:00
function T.xcode3.PBXFileReference_ListResourcesCorrectly()
files {
"English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib"
2009-08-24 21:42:14 +00:00
}
prepare()
xcode.PBXFileReference(ctx)
test.capture [[
/* Begin PBXFileReference section */
2009-09-03 18:11:41 +00:00
[MainMenu.xib:file] /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
[MainMenu.xib:file(2)] /* French */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = French; path = French.lproj/MainMenu.xib; sourceTree = "<group>"; };
2009-08-24 21:42:14 +00:00
]]
end
2009-08-26 20:42:27 +00:00
function T.xcode3.PBXFileReference_SeparatesResourcesByProject()
files { "MyProject/English.lproj/MainMenu.xib", "MyProject/French.lproj/MainMenu.xib" }
project2()
files { "MyProject2/English.lproj/MainMenu.xib", "MyProject2/French.lproj/MainMenu.xib" }
prepare()
xcode.PBXFileReference(ctx)
test.capture [[
/* Begin PBXFileReference section */
2009-09-03 18:11:41 +00:00
[MainMenu.xib:file] /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
[MainMenu.xib:file(2)] /* French */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = French; path = French.lproj/MainMenu.xib; sourceTree = "<group>"; };
[MainMenu.xib:file(3)] /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
[MainMenu.xib:file(4)] /* French */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = French; path = French.lproj/MainMenu.xib; sourceTree = "<group>"; };
]]
end
function T.xcode3.PBXFileReference_ListFrameworksCorrectly()
links { "Cocoa.framework" }
prepare()
xcode.PBXFileReference(ctx)
test.capture [[
/* Begin PBXFileReference section */
2009-09-03 18:11:41 +00:00
[Cocoa.framework:file] /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
]]
end
2009-09-02 22:18:49 +00:00
function T.xcode3.PBXFileReference_ListPListCorrectly()
files { "Info.plist" }
prepare()
xcode.PBXFileReference(ctx)
test.capture [[
/* Begin PBXFileReference section */
2009-09-03 18:11:41 +00:00
[Info.plist:file] /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Info.plist; sourceTree = "<group>"; };
[MyProject:file] /* MyProject */ = {isa = PBXFileReference; explicitFileType = compiled.mach-o.executable; includeInIndex = 0; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
2009-09-02 22:18:49 +00:00
/* End PBXFileReference section */
]]
end
--
-- PBXFrameworksBuildPhase section tests
--
function T.xcode3.PBXFrameworksBuild_OnNoFiles()
prepare()
xcode.PBXFrameworksBuildPhase(ctx)
test.capture [[
/* Begin PBXFrameworksBuildPhase section */
2009-09-03 18:11:41 +00:00
[MyProject:frameworks] /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
]]
end
function T.xcode3.PBXFrameworksBuild_ListsFrameworksCorrectly()
links { "Cocoa.framework" }
prepare()
xcode.PBXFrameworksBuildPhase(ctx)
test.capture [[
/* Begin PBXFrameworksBuildPhase section */
2009-09-03 18:11:41 +00:00
[MyProject:frameworks] /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2009-09-03 18:11:41 +00:00
[Cocoa.framework:build] /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
]]
end
--
-- PBXGroup section tests
--
function T.xcode3.PBXGroup_OnNoFiles()
prepare()
xcode.PBXGroup(ctx)
test.capture [[
/* Begin PBXGroup section */
2009-09-03 18:11:41 +00:00
[MyProject] /* MyProject */ = {
isa = PBXGroup;
children = (
2009-09-03 18:11:41 +00:00
[Resources] /* Resources */,
[Frameworks] /* Frameworks */,
);
name = MyProject;
sourceTree = "<group>";
};
/* End PBXGroup section */
]]
end
function T.xcode3.PBXGroup_RootFilesInMainGroup()
files { "source.h" }
prepare()
xcode.PBXGroup(ctx)
test.capture [[
/* Begin PBXGroup section */
2009-09-03 18:11:41 +00:00
[MyProject] /* MyProject */ = {
isa = PBXGroup;
children = (
2009-09-03 18:11:41 +00:00
[source.h:file] /* source.h */,
[Resources] /* Resources */,
[Frameworks] /* Frameworks */,
);
name = MyProject;
sourceTree = "<group>";
};
/* End PBXGroup section */
]]
end
function T.xcode3.PBXGroup_CreateSubGroups()
files { "include/source.h" }
prepare()
xcode.PBXGroup(ctx)
test.capture [[
/* Begin PBXGroup section */
2009-09-03 18:11:41 +00:00
[MyProject] /* MyProject */ = {
isa = PBXGroup;
children = (
2009-09-03 18:11:41 +00:00
[include] /* include */,
[Resources] /* Resources */,
[Frameworks] /* Frameworks */,
);
name = MyProject;
sourceTree = "<group>";
};
2009-09-03 18:11:41 +00:00
[include] /* include */ = {
isa = PBXGroup;
children = (
2009-09-03 18:11:41 +00:00
[source.h:file] /* source.h */,
);
name = include;
path = include;
sourceTree = "<group>";
};
/* End PBXGroup section */
]]
end
2009-08-27 13:27:47 +00:00
function T.xcode3.PBXGroup_CreatesResourceSubgroup()
2009-09-02 22:18:49 +00:00
files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib", "Info.plist" }
2009-08-27 13:27:47 +00:00
prepare()
xcode.PBXGroup(ctx)
test.capture [[
/* Begin PBXGroup section */
2009-09-03 18:11:41 +00:00
[MyProject] /* MyProject */ = {
2009-08-27 13:27:47 +00:00
isa = PBXGroup;
children = (
2009-09-03 18:11:41 +00:00
[Resources] /* Resources */,
[Frameworks] /* Frameworks */,
2009-08-27 13:27:47 +00:00
);
name = MyProject;
sourceTree = "<group>";
};
2009-09-03 18:11:41 +00:00
[Resources] /* Resources */ = {
2009-08-27 13:27:47 +00:00
isa = PBXGroup;
children = (
2009-09-03 18:11:41 +00:00
[MainMenu.xib:group] /* MainMenu.xib */,
[Info.plist:file] /* Info.plist */,
2009-08-27 13:27:47 +00:00
);
name = Resources;
sourceTree = "<group>";
};
/* End PBXGroup section */
]]
end
2009-08-26 20:42:27 +00:00
--
-- PBXVariantGroup section tests
--
function T.xcode3.PBXVariantGroup_ListsResourceGroups()
files {
"English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib"
}
prepare()
xcode.PBXVariantGroup(ctx)
test.capture [[
/* Begin PBXVariantGroup section */
2009-09-03 18:11:41 +00:00
[MainMenu.xib:group] /* MainMenu.xib */ = {
2009-08-26 20:42:27 +00:00
isa = PBXVariantGroup;
children = (
2009-09-03 18:11:41 +00:00
[MainMenu.xib:file(2)] /* French */,
[MainMenu.xib:file] /* English */,
2009-08-26 20:42:27 +00:00
);
name = MainMenu.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
]]
end