Commits

Jason Perkins committed 5edee63

Clean up pass over output APIs used by exporters
- Reworked _p() and _x() over new indentation-aware output APIs
- Added proper APIs for setting indentation, EOL sequence, and value escaping
- Moved functions intended for exporters to premake.lua (with generation and validation calls)

Comments (0)

Files changed (28)

src/actions/make/_make.lua

 		},
 
 		onsolution = function(sln)
-			io.esc = make.esc
+			premake.escaper(make.esc)
 			premake.generate(sln, make.getmakefilename(sln, false), make.generate_solution)
 		end,
 
 		onproject = function(prj)
-			io.esc = make.esc
+			premake.escaper(make.esc)
 			local makefile = make.getmakefilename(prj, true)
 			if project.isdotnet(prj) then
 				premake.generate(prj, makefile, make.cs.generate)

src/actions/make/make_cpp.lua

 	}
 
 	function make.cpp.generate(prj)
+		io.eol("\n")
 		premake.callarray(make, cpp.elements.makefile, prj)
 	end
 

src/actions/make/make_csharp.lua

 --
 
 	function make.cs.generate(prj)
+		premake.eol("\n")
 		local toolset = premake.tools.dotnet
 		premake.callarray(make, cs.elements.makefile, prj, toolset)
 	end

src/actions/make/make_solution.lua

 --
 
 	function make.generate_solution(sln)
+		premake.eol("\n")
+
 		make.header(sln)
 
 		make.configmap(sln)

src/actions/vstudio/vs2005.lua

 --
 -- actions/vstudio/vs2005.lua
 -- Add support for the  Visual Studio 2005 project formats.
--- Copyright (c) 2008-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2008-2014 Jason Perkins and the Premake project
 --
 
 	premake.vstudio.vs2005 = {}
-	local vs2005 = premake.vstudio.vs2005
-	local vstudio = premake.vstudio
+
+	local p = premake
+	local vs2005 = p.vstudio.vs2005
+	local vstudio = p.vstudio
 
 
 ---
 ---
 
 	function vs2005.generateSolution(sln)
-		io.indent = nil -- back to default
-		io.eol = "\r\n"
-		io.esc = vs2005.esc
+		p.indent("\t")
+		p.eol("\r\n")
+		p.escaper(vs2005.esc)
 
 		premake.generate(sln, ".sln", vstudio.sln2005.generate)
 	end
 
 
 	function vs2005.generateProject(prj)
-		io.eol = "\r\n"
-		io.esc = vs2005.esc
+		p.indent("  ")
+		p.eol("\r\n")
+		p.escaper(vs2005.esc)
 
 		if premake.project.isdotnet(prj) then
 			premake.generate(prj, ".csproj", vstudio.cs2005.generate)

src/actions/vstudio/vs2005_csproj.lua

 --
 -- vs2005_csproj.lua
 -- Generate a Visual Studio 2005-2010 C# project.
--- Copyright (c) 2009-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
 --
 
 	premake.vstudio.cs2005 = {}
 
-	local vstudio = premake.vstudio
-	local cs2005  = premake.vstudio.cs2005
-	local project = premake.project
-	local config = premake.config
-	local fileconfig = premake.fileconfig
-	local dotnet = premake.tools.dotnet
+	local p = premake
+	local vstudio = p.vstudio
+	local cs2005  = p.vstudio.cs2005
+	local project = p.project
+	local config = p.config
+	local fileconfig = p.fileconfig
+	local dotnet = p.tools.dotnet
 
 
 	cs2005.elements = {}
 	}
 
 	function cs2005.generate(prj)
-		io.indent = "  "
-		io.eol = "\r\n"
 		io.utf8()
 
 		premake.callarray(cs2005, cs2005.elements.project, prj)
 		cs2005.targets(prj)
 		cs2005.buildEvents(prj)
 
-		io.printf('</Project>')
+		p.out('</Project>')
 	end
 
 
 				-- Process any sub-elements required by this file; choose the write
 				-- element form to use based on the results.
 
-				local contents = io.capture(function ()
+				local contents = premake.capture(function ()
 					for _, el in ipairs(elements) do
 						local value = info[el]
 						if value then

src/actions/vstudio/vs2005_csproj_user.lua

 --
 -- vs2005_csproj_user.lua
 -- Generate a Visual Studio 2005/2008 C# .user file.
--- Copyright (c) 2009-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
 --
 
-	local cs2005 = premake.vstudio.cs2005
-	local project = premake.project
+	local p = premake
+	local cs2005 = p.vstudio.cs2005
+	local project = p.project
 
 
 --
 --
 
 	function cs2005.generate_user(prj)
-		io.indent = "  "
-
 		_p('<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">')
 		_p(1,'<PropertyGroup>')
 

src/actions/vstudio/vs200x_vcproj.lua

 	end
 
 	function m.generate(prj)
+		p.indent("\t")
 		p.callArray(m.elements.project, prj)
 		p.pop('</VisualStudioProject>')
 	end
 		-- element and capture the results to a buffer. I will only
 		-- write the file configuration if the buffers are not empty.
 
-		local configAttribs = io.capture(function ()
+		local configAttribs = p.capture(function ()
 			p.push()
 			m.fileConfiguration_extraAttributes(cfg, filecfg)
 			p.pop()
 		end)
 
-		local compilerAttribs = io.capture(function ()
+		local compilerAttribs = p.capture(function ()
 			p.push(2)
 			m.fileConfiguration_compilerAttributes(cfg, filecfg)
 			p.pop(2)
 			p.push('<FileConfiguration')
 			p.w('Name="%s"', vstudio.projectConfig(cfg))
 			if #configAttribs > 0 then
-				_p("%s", configAttribs)
+				p.outln(configAttribs)
 			end
 			p.w('>')
 
 			p.push('<Tool')
 			if #compilerAttribs > 0 then
-				_p("%s", compilerAttribs)
+				p.outln(compilerAttribs)
 			end
 			p.pop('/>')
 

src/actions/vstudio/vs200x_vcproj_user.lua

 --
 
 	function m.generate_user(prj)
+		p.indent("\t")
 		m.xmlElement()
 		p.push('<VisualStudioUserFile')
 		p.w('ProjectType="Visual C++"')

src/actions/vstudio/vs2010.lua

 --
 
 	premake.vstudio.vs2010 = {}
-	local vs2010 = premake.vstudio.vs2010
-	local vstudio = premake.vstudio
-	local project = premake.project
-	local tree = premake.tree
+
+	local p = premake
+	local vs2010 = p.vstudio.vs2010
+	local vstudio = p.vstudio
+	local project = p.project
+	local tree = p.tree
 
 
 ---
 ---
 
 	function vs2010.generateProject(prj)
-		io.eol = "\r\n"
-		io.esc = vs2010.esc
+		p.eol("\r\n")
+		p.indent("  ")
+		p.escaper(vs2010.esc)
 
 		if premake.project.isdotnet(prj) then
 			premake.generate(prj, ".csproj", vstudio.cs2005.generate)

src/actions/vstudio/vs2010_vcxproj.lua

 --
 -- vs2010_vcxproj.lua
 -- Generate a Visual Studio 201x C/C++ project.
--- Copyright (c) 2009-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
 --
 
 	premake.vstudio.vc2010 = {}
 
-	local vc2010 = premake.vstudio.vc2010
-	local vstudio = premake.vstudio
-	local project = premake.project
-	local config = premake.config
-	local fileconfig = premake.fileconfig
-	local tree = premake.tree
+	local p = premake
+	local vc2010 = p.vstudio.vc2010
+	local vstudio = p.vstudio
+	local project = p.project
+	local config = p.config
+	local fileconfig = p.fileconfig
+	local tree = p.tree
 
 
 ---
 --
 
 	function vc2010.generate(prj)
-		io.indent = "  "
 		io.utf8()
 
 		vc2010.xmlDeclaration()
 
 		vc2010.import(prj)
 
-		io.printf('</Project>')
+		p.out('</Project>')
 	end
 
 
 	end
 
 	function vc2010.linkStatic(cfg, explicit)
-		local contents = io.capture(function ()
+		local contents = p.capture(function ()
 			premake.callarray(vc2010, vc2010.elements.linkStatic, cfg, explicit)
 		end)
 		if #contents > 0 then
 				-- Capture the contents of the <ClCompile> element, if any, so
 				-- I know which form to use.
 
-				local contents = io.capture(function ()
+				local contents = p.capture(function ()
 					for cfg in project.eachconfig(prj) do
 						local condition = vc2010.condition(cfg)
 
 
 	function vc2010.nmakeCommandLine(cfg, commands, phase)
 		if #commands > 0 then
-			commands = table.concat(premake.esc(commands), io.eol)
+			commands = table.concat(premake.esc(commands), p.eol())
 			_p(2, '<NMake%sCommandLine>%s</NMake%sCommandLine>', phase, commands, phase)
 		end
 	end

src/actions/vstudio/vs2010_vcxproj_filters.lua

 --
 -- vs2010_vcxproj_filters.lua
 -- Generate a Visual Studio 201x C/C++ filters file.
--- Copyright (c) 2009-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
 --
 
-	local vc2010 = premake.vstudio.vc2010
-	local project = premake.project
-	local tree = premake.tree
+	local p = premake
+	local vc2010 = p.vstudio.vc2010
+	local project = p.project
+	local tree = p.tree
 
 
 --
 --
 
 	function vc2010.generateFilters(prj)
-		io.indent = "  "
-
 		vc2010.xmlDeclaration()
 		vc2010.project()
 
 		vc2010.filters_filegroup(prj, "ResourceCompile")
 		vc2010.filters_filegroup(prj, "CustomBuild")
 
-		io.printf('</Project>')
+		p.out('</Project>')
 	end
 
 

src/actions/vstudio/vs2010_vcxproj_user.lua

 -- Copyright (c) 2011-2013 Jason Perkins and the Premake project
 --
 
-	local vstudio = premake.vstudio
-	local vc2010 = premake.vstudio.vc2010
-	local project = premake.project
+	local p = premake
+	local vstudio = p.vstudio
+	local vc2010 = p.vstudio.vc2010
+	local project = p.project
 
 
 --
 --
 
 	function vc2010.generateUser(prj)
-		io.indent = "  "
-
 		vc2010.xmlDeclaration()
 		vc2010.project()
 		for cfg in project.eachconfig(prj) do

src/base/_foundation.lua

 
 -- Keep track of warnings that have been shown, so they don't get shown twice
 
-	local warnings = {}
+	local _warnings = {}
 
 
 --
 	end
 
 
+
 ---
 -- Clears the list of already fired warning messages, allowing them
 -- to be fired again.
 ---
 
 	function premake.clearWarnings()
-		warnings = {}
+		_warnings = {}
 	end
 
 
+
 --
 -- Raise an error, with a formatted message built from the provided
 -- arguments.
 	end
 
 
+
 ---
 -- Override an existing function with a new implementation; the original
 -- function is passed as the first argument to the replacement when called.
 	end
 
 
---
--- A shortcut for printing formatted output.
---
-
-	function printf(msg, ...)
-		print(string.format(msg, unpack(arg)))
-	end
-
 
 --
 -- Display a warning, with a formatted message built from the provided
 --
 
 	function premake.warnOnce(key, message, ...)
-		if not warnings[key] then
-			warnings[key] = true
+		if not _warnings[key] then
+			_warnings[key] = true
 			premake.warn(message, ...)
 		end
 	end
+
+
+
+--
+-- A shortcut for printing formatted output.
+--
+
+	function printf(msg, ...)
+		print(string.format(msg, unpack(arg)))
+	end
 --
 -- io.lua
 -- Additions to the I/O namespace.
--- Copyright (c) 2008-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2008-2014 Jason Perkins and the Premake project
 --
 
 
----
--- Capture and store everything sent through io.printf() during the
--- execution of the supplied function.
---
--- @param fn
---    The function to execute. All calls to io.printf() will be
---    caught and stored.
--- @return
---    The captured output.
----
-
-	function io.capture(fn)
-		-- start a new capture without forgetting the old one
-		local old = io._captured
-		io._captured = {}
-
-		-- capture
-		fn()
-
-		-- build the result
-		local captured = io.captured()
-
-		-- restore the old capture and done
-		io._captured = old
-		io._captured_string = nil
-		return captured
-	end
-
-
-
---
--- Returns the captured text and stops capturing.
---
-
-	function io.captured()
-		if io._captured then
-			if not io._captured_string and #io._captured > 0 then
-				io._captured_string = table.concat(io._captured, io.eol)
-			end
-			return io._captured_string or ""
-		end
-	end
-
-
 --
 -- Open an overload of the io.open() function, which will create any missing
 -- subdirectories in the filename if "mode" is set to writeable.
 --
 
 	premake.override(io, "open", function(base, fname, mode)
-		if mode then
-			if mode:find("w") then
-				local dir = path.getdirectory(fname)
-				ok, err = os.mkdir(dir)
-				if not ok then
-					error(err, 0)
-				end
+		if mode and mode:find("w") then
+			local dir = path.getdirectory(fname)
+			ok, err = os.mkdir(dir)
+			if not ok then
+				error(err, 0)
 			end
 		end
 		return base(fname, mode)
 	end)
 
 
-
---
--- A shortcut for printing formatted output to an output stream.
---
-
-	function io.printf(msg, ...)
-		local s
-		if type(msg) == "number" then
-			s = string.rep(io.indent or "\t", msg) .. string.format(...)
-		else
-			s = string.format(msg, ...)
-		end
-
-		if not io._captured then
-			io.write(s)
-		else
-			table.insert(io._captured, s)
-			io._captured_string = nil
-		end
-	end
-
-
 --
 -- Output a UTF-8 signature.
 --
 	function io.utf8()
 		io.write('\239\187\191')
 	end
-
-
---
--- Because I use io.printf() so often in the generators, create a terse shortcut
--- for it. This saves me typing, and also reduces the size of the executable.
---
-
-	function _p(msg, ...)
-		io.printf(msg, ...)
-		if not io._captured then
-			io.write(io.eol or "\n")
-		end
-	end
-
-
---
--- Another variation that calls io.esc() on all of its arguments before
--- write out the formatting string.
---
-
-	function _x(msg, ...)
-		for i = 2, #arg do
-			arg[i] = premake.esc(arg[i])
-		end
-		_p(msg, unpack(arg))
-	end

src/base/premake.lua

 --
 -- premake.lua
 -- High-level helper functions for the project exporters.
--- Copyright (c) 2002-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2002-2014 Jason Perkins and the Premake project
 --
 
 	local solution = premake.solution
 	local config = premake.config
 
 
-	premake.indentation = 0
+-- Store captured output text for later testing
+
+	local _captured
+
+-- The string escaping function.
+
+	local _esc = function(v) return v end
+
+-- The output settings and defaults
+
+	local _eol = "\n"
+	local _indentString = "\t"
+	local _indentLevel = 0
+
 
 
 ---
--- Call the io.esc() value escaping function a value, or a list
--- of values.
+-- Capture and store everything sent through the output stream functions
+-- premake.w(), premake.x(), and premake.out(). Retrieve the captured
+-- text using the premake.captured() function.
+--
+-- @param fn
+--    A function to execute. Any output calls made during the execution
+--    of the function will be captured.
+-- @return
+--    The captured output.
+---
+
+	function premake.capture(fn)
+		-- start a new capture without forgetting the old one
+		local old = _captured
+		_captured = {}
+
+		-- capture
+		fn()
+
+		-- build the result
+		local captured = premake.captured()
+
+		-- restore the old capture and done
+		_captured = old
+		return captured
+	end
+
+
+
+--
+-- Returns the captured text and stops capturing.
+--
+
+	function premake.captured()
+		if _captured then
+			return table.concat(_captured, _eol)
+		else
+			return ""
+		end
+	end
+
+
+
+---
+-- Set the output stream end-of-line sequence.
+--
+-- @param s
+--    The string to use to mark line ends, or nil to keep the existing
+--    EOL sequence.
+-- @return
+--    The new EOL sequence.
+---
+
+	function premake.eol(s)
+		_eol = s or _eol
+		return _eol
+	end
+
+
+
+---
+-- Handle escaping of strings for various outputs.
 --
 -- @param value
---    Either a single string value, or an array of string values.
---    If an array, it may contain nested sub-arrays.
+--    If this is a string: escape it and return the new value. If it is an
+--    array, return a new array of escaped values.
 -- @return
---    Either a single, esacaped string value, or a new array of
---    escaped string values.
+--    If the input was a single string, returns the escaped version. If it
+--    was an array, returns an corresponding array of escaped strings.
 ---
 
 	function premake.esc(value)
-		if not io.esc then
-			return value
+		if type(value) == "table" then
+			local result = {}
+			local n = #value
+			for i = 1, n do
+				table.insert(result, premake.esc(value[i]))
+			end
+			return result
 		end
 
-		if type(value) == "table" then
-			local result = {}
-			table.foreachi(value, function(v)
-				table.insert(result, premake.esc(v))
-			end)
-			return result
-		else
-			if io.esc then
-				value = io.esc(value)
-			end
-			return value
+		return _esc(value or "")
+	end
+
+
+
+---
+-- Set a new string escaping function.
+--
+-- @param func
+--    The new escaping function, which should take a single string argument
+--    and return the escaped version of that string. If nil, uses a default
+--    no-op function.
+---
+
+	function premake.escaper(func)
+		_esc = func
+		if not _esc then
+			_esc = function (value) return value end
 		end
 	end
 
 
+
 --
 -- Open a file for output, and call a function to actually do the writing.
 -- Used by the actions to generate solution and project files.
 			error(err, 0)
 		end
 
-		premake.indentation = 0
-
 		io.output(f)
 		callback(obj)
 		f:close()
 
 
 ---
+-- Sets the output indentation parameters.
+--
+-- @param s
+--    The indentation string.
+-- @param i
+--    The new indentation level, or nil to reset to zero.
+---
+
+	function premake.indent(s, i)
+		_indentString = s or "\t"
+		_indentLevel = i or 0
+	end
+
+
+
+---
+-- Write a simple, unformatted string to the output stream, with no indentation
+-- or end of line sequence.
+---
+
+	function premake.out(s)
+		if not _captured then
+			io.write(s)
+		else
+			table.insert(_captured, s)
+		end
+	end
+
+
+
+---
+-- Write a simple, unformatted string to the output stream, with no indentation,
+-- and append the current EOL sequence.
+---
+
+	function premake.outln(s)
+		if not _captured then
+			io.write(s)
+			io.write(_eol or "\n")
+		else
+			table.insert(_captured, s)
+		end
+	end
+
+
+
+---
 -- Write a formatted string to the exported file, after decreasing the
 -- indentation level by one.
 --
 
 	function premake.pop(i, ...)
 		if i == nil or type(i) == "number" then
-			premake.indentation = premake.indentation - (i or 1)
+			_indentLevel = _indentLevel - (i or 1)
 		else
-			premake.indentation = premake.indentation - 1
+			_indentLevel = _indentLevel - 1
 			premake.w(i, ...)
 		end
 	end
 
 	function premake.push(i, ...)
 		if i == nil or type(i) == "number" then
-			premake.indentation = premake.indentation + (i or 1)
+			_indentLevel = _indentLevel + (i or 1)
 		else
 			premake.w(i, ...)
-			premake.indentation = premake.indentation + 1
+			_indentLevel = _indentLevel + 1
 		end
 	end
 
 
 
---
+---
 -- Wrap the provided value in double quotes if it contains spaces, or
 -- if it contains a shell variable of the form $(...).
---
+---
 
 	function premake.quoted(value)
 		local q = value:find(" ", 1, true)
 	end
 
 
+
 --
 -- Sanity check the project information loaded from the scripts, to
 -- make sure it all meets some minimum requirements. Raises an error if
 	end
 
 
+
 --
 -- Sanity check the settings of a specific configuration. Raises an error
 -- if an insane state is detected.
 	end
 
 
+
 --
 -- Check the values stored in a configuration object (solution, project, or
 -- configuration) for values that might have been set out of scope.
 
 
 ---
--- Write a formatted string to the exported file (the indentation
--- level is not changed). This gets called quite a lot, hence the
--- very short name.
+-- Write a formatted string to the exported file, at the current
+-- level of indentation, and appends an end of line sequence.
+-- This gets called quite a lot, hence the very short name.
 ---
 
 	function premake.w(...)
 		if select("#",...) > 0 then
-			_p(premake.indentation, ...)
+			premake.outln(string.rep(_indentString or "\t", _indentLevel) .. string.format(...))
 		else
-			_p('')
+			premake.outln('');
 		end
 	end
 
 		end
 		premake.w(msg, unpack(arg))
 	end
+
+
+
+--
+-- These are the output shortcuts that I used before switching to the
+-- indentation-aware calls above. They are still in use all over the
+-- place, including lots of community code, so let's keep them around.
+--
+-- @param i
+--    This will either be a printf-style formatting string suitable
+--    for passing to string.format(), OR an integer number indicating
+--    the desired level of indentation. If the latter, the formatting
+--    string should be the next argument in the list.
+-- @param ...
+--    The values necessary to fill out the formatting string tokens.
+--
+
+	function _p(i, ...)
+		if type(i) == "number" then
+			_indentLevel = i
+			premake.w(...)
+		else
+			_indentLevel = 0
+			premake.w(i, ...)
+		end
+	end
+
+	function _x(i, ...)
+		for i = 2, #arg do
+			arg[i] = premake.esc(arg[i])
+		end
+		_p(i, unpack(arg))
+	end

tests/actions/vstudio/cs2005/test_build_events.lua

 	local sln, prj, cfg
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2010.esc
+		premake.escaper(premake.vstudio.vs2010.esc)
 		sln = test.createsolution()
 	end
 

tests/actions/vstudio/sln2005/test_projects.lua

 	local sln
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2005.esc
+		premake.escaper(premake.vstudio.vs2005.esc)
 		sln = solution "MySolution"
 		configurations { "Debug", "Release" }
 		language "C++"

tests/actions/vstudio/vc200x/test_build_steps.lua

 	local sln, prj
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2005.esc
+		premake.escaper(premake.vstudio.vs2005.esc)
 		sln, prj = test.createsolution()
 	end
 

tests/actions/vstudio/vc200x/test_debug_settings.lua

 	local sln, prj
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2005.esc
+		premake.escaper(premake.vstudio.vs2005.esc)
 		sln, prj = test.createsolution()
 	end
 

tests/actions/vstudio/vc200x/test_files.lua

 	local sln, prj
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2005.esc
+		premake.escaper(premake.vstudio.vs2005.esc)
 		sln = test.createsolution()
 	end
 

tests/actions/vstudio/vc200x/test_linker_block.lua

 
 	function suite.setup()
 		_ACTION = "vs2008"
-		io.esc = premake.vstudio.vs2005.esc
+		premake.escaper(premake.vstudio.vs2005.esc)
 		sln, prj = test.createsolution()
 	end
 

tests/actions/vstudio/vc200x/test_nmake_settings.lua

 	local sln, prj
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2005.esc
+		premake.escaper(premake.vstudio.vs2005.esc)
 		sln, prj = test.createsolution()
 		kind "Makefile"
 	end

tests/actions/vstudio/vc2010/test_build_events.lua

 	local sln, prj, cfg
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2010.esc
+		premake.escaper(premake.vstudio.vs2010.esc)
 		sln = test.createsolution()
 	end
 

tests/actions/vstudio/vc2010/test_resource_compile.lua

 	local sln, prj
 
 	function suite.setup()
-		io.esc = premake.vstudio.vs2010.esc
+		premake.escaper(premake.vstudio.vs2010.esc)
 		sln, prj = test.createsolution()
 	end
 

tests/base/test_include.lua

 
 	function suite.include_findsPremakeFile_onFolderNameOnly()
 		include "folder"
-		test.isequal("ok", io.captured())
+		test.isequal("ok", premake.captured())
 	end
 
 
 	function suite.include_onExactFilename()
 		include "folder/premake4.lua"
-		test.isequal("ok", io.captured())
+		test.isequal("ok", premake.captured())
 	end
 
 
 	function suite.include_runsOnlyOnce_onMultipleIncludes()
 		include "folder/premake4.lua"
 		include "folder/premake4.lua"
-		test.isequal("ok", io.captured())
+		test.isequal("ok", premake.captured())
 	end
 
 
 	function suite.include_runsOnlyOnce_onMultipleIncludesWithDifferentPaths()
 		include "folder/premake4.lua"
 		include "../tests/folder/premake4.lua"
-		test.isequal("ok", io.captured())
+		test.isequal("ok", premake.captured())
 	end

tests/folder/premake4.lua

-io.printf("ok")
+premake.out("ok")
 --
 -- tests/testfx.lua
 -- Automated test framework for Premake.
--- Copyright (c) 2008-2013 Jason Perkins and the Premake project
+-- Copyright (c) 2008-2014 Jason Perkins and the Premake project
 --
 
 
 --
 
 	function test.capture(expected)
-
-		local actual = io.captured() .. io.eol
+		local actual = premake.captured() .. premake.eol()
 
 		-- create line-by-line iterators for both values
-		local ait = actual:gfind("(.-)" .. io.eol)
+		local ait = actual:gfind("(.-)" .. premake.eol())
 		local eit = expected:gfind("(.-)\n")
 
 		-- compare each value line by line
 
 
 	function test.isemptycapture()
-		local actual = io.captured()
+		local actual = premake.captured()
 		if actual ~= "" then
 			test.fail("expected empty capture, but was %s", actual);
 		end
 		premake.solution.list = { }
 		premake.api.reset()
 		premake.clearWarnings()
-		premake.indentation = 0
-
-		io.indent = nil
-		io.eol = "\n"
-		io.esc = nil
+		premake.eol("\n")
+		premake.escaper(nil)
+		premake.indent("\t")
 
 		-- reset captured I/O values
 		test.value_openedfilename = nil
 
 	local function test_run(suite, fn)
 		local result, err
-		io.capture(function()
+		premake.capture(function()
 			result, err = xpcall(fn, error_handler)
 		end)
 		return result, err