Module Name:    src
Committed By:   rillig
Date:           Mon May 22 06:35:56 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: t_options.lua

Log Message:
tests/indent: skip creating an intermediate file in tests


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/t_options.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/t_options.lua
diff -u src/tests/usr.bin/indent/t_options.lua:1.3 src/tests/usr.bin/indent/t_options.lua:1.4
--- src/tests/usr.bin/indent/t_options.lua:1.3	Sun May 21 10:18:44 2023
+++ src/tests/usr.bin/indent/t_options.lua	Mon May 22 06:35:56 2023
@@ -1,4 +1,4 @@
--- $NetBSD: t_options.lua,v 1.3 2023/05/21 10:18:44 rillig Exp $
+-- $NetBSD: t_options.lua,v 1.4 2023/05/22 06:35:56 rillig Exp $
 --
 -- Copyright (c) 2023 The NetBSD Foundation, Inc.
 -- All rights reserved.
@@ -24,6 +24,8 @@
 -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 -- POSSIBILITY OF SUCH DAMAGE.
 
+-- usage: [INDENT=...] lua t_options.lua <file>...
+--
 -- Test driver for indent that runs indent on several inputs, checks the
 -- output and can run indent with different command line options on the same
 -- input.
@@ -32,11 +34,11 @@
 -- and the output, all as close together as possible. The test files use the
 -- following directives:
 --
---	//indent input [description]
+--	//indent input
 --		Specifies the input to be formatted.
 --	//indent run [options]
 --		Runs indent on the input, using the given options.
---	//indent end [description]
+--	//indent end
 --		Finishes an '//indent input' or '//indent run' section.
 --	//indent run-equals-input [options]
 --		Runs indent on the input, expecting unmodified output.
@@ -124,16 +126,14 @@ end
 
 local function run_indent(inp, args)
 	local indent = os.getenv("INDENT") or "indent"
-	local cmd = indent .. " " .. args .. " indent.in -st"
+	local cmd = indent .. " " .. args .. " 2>&1"
 
-	local indent_in = assert(io.open("indent.in", "w"))
+	local indent_in = assert(io.popen(cmd, "w"))
 	indent_in:write(inp)
-	indent_in:close()
-	local ok, kind, info = os.execute(cmd)
+	local ok, kind, info = indent_in:close()
 	if not ok then
 		print(kind .. " " .. info)
 	end
-	os.remove("indent.in")
 end
 
 local function handle_empty_section(line)
@@ -236,7 +236,9 @@ local function handle_indent_directive(l
 	print(line)
 	expected_out:write(line .. "\n")
 
-	if command == "input" and args == "" then
+	if command == "input" and args ~= "" then
+		warn(lineno, "'//indent input' does not take arguments")
+	elseif command == "input" then
 		handle_indent_input()
 	elseif command == "run" then
 		handle_indent_run(args)

Reply via email to