Initial community commit

This commit is contained in:
Jef
2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit 20d28e80a5
16810 changed files with 4640254 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
require ("d")
return {
"test_visualstudio.lua",
"test_gmake.lua",
"test_dmd.lua",
"test_gdc.lua",
"test_ldc.lua",
}

View File

@@ -0,0 +1,106 @@
---
-- d/tests/test_dmd.lua
-- Automated test suite for dmd.
-- Copyright (c) 2011-2015 Manu Evans and the Premake project
---
local suite = test.declare("d_dmd")
local p = premake
local m = p.modules.d
local make = p.make
local project = p.project
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
function suite.setup()
p.escaper(make.esc)
wks = test.createWorkspace()
end
local function prepare_cfg(calls)
prj = p.workspace.getproject(wks, 1)
local cfg = test.getconfig(prj, "Debug")
local toolset = p.tools.dmd
p.callArray(calls, cfg, toolset)
end
--
-- Check configuration generation
--
function suite.dmd_dTools()
prepare_cfg({ m.make.dTools })
test.capture [[
DC = dmd
]]
end
function suite.dmd_target()
prepare_cfg({ m.make.target })
test.capture [[
]]
end
function suite.dmd_target_separateCompilation()
compilationmodel "File"
prepare_cfg({ m.make.target })
test.capture [[
OUTPUTFLAG = -of"$@"
]]
end
function suite.dmd_versions()
versionlevel (10)
versionconstants { "A", "B" }
prepare_cfg({ m.make.versions })
test.capture [[
VERSIONS += -version=A -version=B -version=10
]]
end
function suite.dmd_debug()
debuglevel (10)
debugconstants { "A", "B" }
prepare_cfg({ m.make.debug })
test.capture [[
DEBUG += -debug=A -debug=B -debug=10
]]
end
function suite.dmd_imports()
importdirs { "dir1", "dir2/" }
prepare_cfg({ m.make.imports })
test.capture [[
IMPORTS += -Idir1 -Idir2
]]
end
function suite.dmd_dFlags()
prepare_cfg({ m.make.dFlags })
test.capture [[
ALL_DFLAGS += $(DFLAGS) -release $(VERSIONS) $(DEBUG) $(IMPORTS) $(STRINGIMPORTS) $(ARCH)
]]
end
function suite.dmd_linkCmd()
prepare_cfg({ m.make.linkCmd })
test.capture [[
BUILDCMD = $(DC) -of$(TARGET) $(ALL_DFLAGS) $(ALL_LDFLAGS) $(LIBS) $(SOURCEFILES)
]]
end
function suite.dmd_linkCmd_separateCompilation()
compilationmodel "File"
prepare_cfg({ m.make.linkCmd })
test.capture [[
LINKCMD = $(DC) -of$(TARGET) $(ALL_LDFLAGS) $(LIBS) $(OBJECTS)
]]
end

View File

@@ -0,0 +1,106 @@
---
-- d/tests/test_dmd.lua
-- Automated test suite for dmd.
-- Copyright (c) 2011-2015 Manu Evans and the Premake project
---
local suite = test.declare("d_gdc")
local p = premake
local m = p.modules.d
local make = p.make
local project = p.project
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
function suite.setup()
p.escaper(make.esc)
wks = test.createWorkspace()
end
local function prepare_cfg(calls)
prj = p.workspace.getproject(wks, 1)
local cfg = test.getconfig(prj, "Debug")
local toolset = p.tools.gdc
p.callArray(calls, cfg, toolset)
end
--
-- Check configuration generation
--
function suite.dmd_dTools()
prepare_cfg({ m.make.dTools })
test.capture [[
DC = gdc
]]
end
function suite.dmd_target()
prepare_cfg({ m.make.target })
test.capture [[
]]
end
function suite.dmd_target_separateCompilation()
compilationmodel "File"
prepare_cfg({ m.make.target })
test.capture [[
OUTPUTFLAG = -o "$@"
]]
end
function suite.dmd_versions()
versionlevel (10)
versionconstants { "A", "B" }
prepare_cfg({ m.make.versions })
test.capture [[
VERSIONS += -fversion=A -fversion=B -fversion=10
]]
end
function suite.dmd_debug()
debuglevel (10)
debugconstants { "A", "B" }
prepare_cfg({ m.make.debug })
test.capture [[
DEBUG += -fdebug=A -fdebug=B -fdebug=10
]]
end
function suite.dmd_imports()
importdirs { "dir1", "dir2/" }
prepare_cfg({ m.make.imports })
test.capture [[
IMPORTS += -Idir1 -Idir2
]]
end
function suite.dmd_dFlags()
prepare_cfg({ m.make.dFlags })
test.capture [[
ALL_DFLAGS += $(DFLAGS) -frelease $(VERSIONS) $(DEBUG) $(IMPORTS) $(STRINGIMPORTS) $(ARCH)
]]
end
function suite.dmd_linkCmd()
prepare_cfg({ m.make.linkCmd })
test.capture [[
BUILDCMD = $(DC) -o $(TARGET) $(ALL_DFLAGS) $(ALL_LDFLAGS) $(LIBS) $(SOURCEFILES)
]]
end
function suite.dmd_linkCmd_separateCompilation()
compilationmodel "File"
prepare_cfg({ m.make.linkCmd })
test.capture [[
LINKCMD = $(DC) -o $(TARGET) $(ALL_LDFLAGS) $(LIBS) $(OBJECTS)
]]
end

View File

@@ -0,0 +1,222 @@
---
-- d/tests/test_gmake.lua
-- Automated test suite for gmake project generation.
-- Copyright (c) 2011-2015 Manu Evans and the Premake project
---
local suite = test.declare("d_make")
local p = premake
local m = p.modules.d
local make = p.make
local project = p.project
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
function suite.setup()
p.escaper(make.esc)
wks = test.createWorkspace()
end
local function prepare()
prj = p.workspace.getproject(wks, 1)
end
local function prepare_cfg(calls)
prj = p.workspace.getproject(wks, 1)
local cfg = test.getconfig(prj, "Debug")
local toolset = m.make.getToolset(cfg) or p.tools.dmd
p.callArray(calls, cfg, toolset)
end
--
-- Check project generation
--
function suite.make_targetRules()
prepare()
m.make.targetRules(prj)
test.capture [[
$(TARGET): $(SOURCEFILES) $(LDDEPS)
@echo Building MyProject
$(SILENT) $(BUILDCMD)
$(POSTBUILDCMDS)
]]
end
function suite.make_targetRules_separateCompilation()
compilationmodel "File"
prepare()
m.make.targetRules(prj)
test.capture [[
$(TARGET): $(OBJECTS) $(LDDEPS)
@echo Linking MyProject
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
]]
end
function suite.make_targetRules_mixedCompilation()
configuration { "Release" }
compilationmodel "File"
prepare()
m.make.targetRules(prj)
test.capture [[
ifeq ($(config),debug)
$(TARGET): $(SOURCEFILES) $(LDDEPS)
@echo Building MyProject
$(SILENT) $(BUILDCMD)
$(POSTBUILDCMDS)
endif
ifeq ($(config),release)
$(TARGET): $(OBJECTS) $(LDDEPS)
@echo Linking MyProject
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
endif
]]
end
function suite.make_fileRules()
files { "blah.d" }
prepare()
m.make.dFileRules(prj)
test.capture [[
]]
end
function suite.make_fileRules_separateCompilation()
files { "blah.d" }
compilationmodel "File"
prepare()
m.make.dFileRules(prj)
test.capture [[
$(OBJDIR)/blah.o: blah.d
@echo $(notdir $<)
$(SILENT) $(DC) $(ALL_DFLAGS) $(OUTPUTFLAG) -c $<
]]
end
function suite.make_fileRules_mixedCompilation()
files { "blah.d" }
configuration { "Release" }
compilationmodel "File"
prepare()
m.make.dFileRules(prj)
test.capture [[
$(OBJDIR)/blah.o: blah.d
@echo $(notdir $<)
$(SILENT) $(DC) $(ALL_DFLAGS) $(OUTPUTFLAG) -c $<
]]
end
function suite.make_objects()
files { "blah.d" }
prepare()
m.make.objects(prj)
test.capture [[
SOURCEFILES := \
blah.d \
]]
end
function suite.make_objects_separateCompilation()
files { "blah.d" }
compilationmodel "File"
prepare()
m.make.objects(prj)
test.capture [[
OBJECTS := \
$(OBJDIR)/blah.o \
]]
end
function suite.make_objects_mixedCompilation()
files { "blah.d" }
configuration { "Release" }
compilationmodel "File"
files { "blah2.d" }
prepare()
m.make.objects(prj)
test.capture [[
SOURCEFILES := \
blah.d \
OBJECTS := \
$(OBJDIR)/blah.o \
ifeq ($(config),release)
SOURCEFILES += \
blah2.d \
OBJECTS += \
$(OBJDIR)/blah2.o \
endif
]]
end
--
-- Check configuration generation
--
function suite.make_allRules()
prepare_cfg({ m.make.allRules })
test.capture [[
all: $(TARGETDIR) prebuild prelink $(TARGET)
@:
]]
end
function suite.make_allRules_separateCompilation()
compilationmodel "File"
prepare_cfg({ m.make.allRules })
test.capture [[
all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET)
@:
]]
end
function suite.make_dTools_dmd()
toolset "dmd"
prepare_cfg({ m.make.dTools })
test.capture [[
DC = dmd
]]
end
function suite.make_dTools_gdc()
toolset "gdc"
prepare_cfg({ m.make.dTools })
test.capture [[
DC = gdc
]]
end
function suite.make_dTools_ldc()
toolset "ldc"
prepare_cfg({ m.make.dTools })
test.capture [[
DC = ldc2
]]
end

View File

@@ -0,0 +1,106 @@
---
-- d/tests/test_dmd.lua
-- Automated test suite for dmd.
-- Copyright (c) 2011-2015 Manu Evans and the Premake project
---
local suite = test.declare("d_ldc")
local p = premake
local m = p.modules.d
local make = p.make
local project = p.project
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
function suite.setup()
p.escaper(make.esc)
wks = test.createWorkspace()
end
local function prepare_cfg(calls)
prj = p.workspace.getproject(wks, 1)
local cfg = test.getconfig(prj, "Debug")
local toolset = p.tools.ldc
p.callArray(calls, cfg, toolset)
end
--
-- Check configuration generation
--
function suite.dmd_dTools()
prepare_cfg({ m.make.dTools })
test.capture [[
DC = ldc2
]]
end
function suite.dmd_target()
prepare_cfg({ m.make.target })
test.capture [[
]]
end
function suite.dmd_target_separateCompilation()
compilationmodel "File"
prepare_cfg({ m.make.target })
test.capture [[
OUTPUTFLAG = -of="$@"
]]
end
function suite.dmd_versions()
versionlevel (10)
versionconstants { "A", "B" }
prepare_cfg({ m.make.versions })
test.capture [[
VERSIONS += -d-version=A -d-version=B -d-version=10
]]
end
function suite.dmd_debug()
debuglevel (10)
debugconstants { "A", "B" }
prepare_cfg({ m.make.debug })
test.capture [[
DEBUG += -d-debug=A -d-debug=B -d-debug=10
]]
end
function suite.dmd_imports()
importdirs { "dir1", "dir2/" }
prepare_cfg({ m.make.imports })
test.capture [[
IMPORTS += -I=dir1 -I=dir2
]]
end
function suite.dmd_dFlags()
prepare_cfg({ m.make.dFlags })
test.capture [[
ALL_DFLAGS += $(DFLAGS) -release $(VERSIONS) $(DEBUG) $(IMPORTS) $(STRINGIMPORTS) $(ARCH)
]]
end
function suite.dmd_linkCmd()
prepare_cfg({ m.make.linkCmd })
test.capture [[
BUILDCMD = $(DC) -of=$(TARGET) $(ALL_DFLAGS) $(ALL_LDFLAGS) $(LIBS) $(SOURCEFILES)
]]
end
function suite.dmd_linkCmd_separateCompilation()
compilationmodel "File"
prepare_cfg({ m.make.linkCmd })
test.capture [[
LINKCMD = $(DC) -of=$(TARGET) $(ALL_LDFLAGS) $(LIBS) $(OBJECTS)
]]
end

View File

@@ -0,0 +1,75 @@
---
-- d/tests/test_visualstudio.lua
-- Automated test suite for VisualD project generation.
-- Copyright (c) 2011-2015 Manu Evans and the Premake project
---
local suite = test.declare("visual_d")
local p = premake
local m = p.modules.d
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
function suite.setup()
p.action.set("vs2010")
-- p.escaper(p.vstudio.vs2005.esc)
p.indent(" ")
wks = workspace "MyWorkspace"
configurations { "Debug", "Release" }
language "D"
kind "ConsoleApp"
end
local function prepare()
prj = project "MyProject"
end
local function prepare_cfg()
prj = project "MyProject"
cfg = test.getconfig(prj, "Debug")
end
--
-- Check sln for the proper project entry
--
function suite.slnProj()
project "MyProject"
language "D"
p.vstudio.sln2005.reorderProjects(wks)
p.vstudio.sln2005.projects(wks)
test.capture [[
Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "MyProject", "MyProject.visualdproj", "{42B5DBC6-AE1F-903D-F75D-41E363076E92}"
EndProject
]]
end
--
-- Project tests
--
function suite.OnProject_header()
prepare()
m.visuald.header(prj)
test.capture [[
<DProject>
]]
end
function suite.OnProject_globals()
prepare()
m.visuald.globals(prj)
test.capture [[
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
]]
end
-- TODO: break up the project gen and make lots more tests...