changeset 1270:d410747a671a

fix scripts/test.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 12 Nov 2018 20:02:50 -0700
parents bcb39089e899
children 48f302bdc187
files scripts/test.luan src/luan/modules/http/Http_test.luan
diffstat 2 files changed, 21 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
diff -r bcb39089e899 -r d410747a671a scripts/test.luan
--- a/scripts/test.luan	Mon Nov 12 19:50:37 2018 -0700
+++ b/scripts/test.luan	Mon Nov 12 20:02:50 2018 -0700
@@ -22,26 +22,23 @@
 local find = String.find or error()
 local init = Http_test.init or error()
 local get_page = Http_test.get_page or error()
+local run_page = Http_test.run_page or error()
 
 
 local function print(...)
 	Io.print_to(Io.stderr,...)
 end
 
-function Io.schemes.site(path)
-	return Io.uri( "luan:http/tools"..path )
-end
-
 local page
 
 init()
 Http.request.parameters.code = "require('luan:Io.luan').print 'hi'"
-page = get_page "/run"
+page = run_page(require("luan:http/tools/Run.luan").respond)
 trim(page) == "hi" or error "failed"
 
 init()
 Http.request.parameters.cmd = "'ab'..'cd'"
-page = get_page "/shell"
+page = run_page(require("luan:http/tools/Shell.luan").respond)
 find(page,"abcd") or error "failed"
 
 
@@ -79,13 +76,13 @@
 init(); get_page "/pil.html"
 init(); get_page "/manual.html"
 init(); get_page "/diff.html"
-init(); get_page "/examples/hi"
-init(); get_page "/examples/hi2"
-init(); get_page "/examples/shell"
+init(); get_page "/examples/hi.html"
+init(); get_page "/examples/hi2.html"
+init(); get_page "/examples/shell.html"
 
 init()
 Http.request.parameters.name = "bob"
-page = get_page "/examples/hi2"
+page = get_page "/examples/hi2.html"
 find(page,"bob") or error "failed"
 
 
diff -r bcb39089e899 -r d410747a671a src/luan/modules/http/Http_test.luan
--- a/src/luan/modules/http/Http_test.luan	Mon Nov 12 19:50:37 2018 -0700
+++ b/src/luan/modules/http/Http_test.luan	Mon Nov 12 20:02:50 2018 -0700
@@ -39,6 +39,20 @@
 	return Http_test.result.read_text()
 end
 
+function Http_test.run_page(page_fn)
+	local old_out = Io.stdout
+	try {
+		function()
+			page_fn()
+			Http_test.text_writer.close()
+		end
+		finally = function()
+			Io.stdout = old_out
+		end
+	}
+	return Http_test.result.read_text()
+end
+
 function Http_test.init()
 	function Http.reset_luan() end
 	Http.request = Http.new_request()