Commits

Igor Baidiuk committed 80adf0d

Completed sketch version of test suite. Need to implement test command

Comments (0)

Files changed (2)

tests/test-suite.lua

 1. Package path to where channels module is located
 2. Test script to execute
 ]])
+local chanPath, testName = arg[1], arg[2]
 -- Search for channels library
-package.path = "%s/?.dll;%s/?.so;%s" % {arg[1], arg[1], package.path}
+package.path = "%s/?.dll;%s/?.so;%s" % {chanPath, chanPath, package.path}
 require "channels"
 -- Load test chunk
 test = {}
-local testChunk = assert(loadfile(arg[2]), "Failed to load %s"%arg[2])
-local results = {pcall(testChunk())}
+local testChunk = assert(loadfile(testName), "Failed to load %s" % testName)
+local results = { pcall(testChunk()) }
+testPassed = results[1]
+table.remove(results, 1)
 
 test.passes = test.passes == nil and true or test.passes
-if test.passes then -- Positive test check
-	return 0
+if test.passes then
+	assert(
+		testPassed,
+		"FAIL: Test %s: \"%s\"" % { testName, results[1] }
+	)
 else -- Negative test check
-	if results[0] == test.passes then
-		if type(test.results) == "string" then
-			assert(
-				results[2] == test.results,
-				"Negative test %s returns unexpected error message\n\texpected: %s\n\tactual: %s"%{arg[2], test.results, results[2]}
-			)
-		end
-	else
+	assert(
+		not testPassed,
+		"FAIL: Negative test %s passed" % testName
+	)
+	if type(test.results) == "string" then
+		assert(
+			test.results == results[1],
+			"FAIL: Negative test %s: unexpected error message\n\texpected: %s\n\tactual: %s" % {testName, test.results, results[1]}
+		)
 	end
 end
 		c.fatal('You must specify Lua SDK location with --lualib-root command line argument')
 	
 	lua_root = c.options.lua_root
+	c.env.BIN_LUALIB        = ['%s/bin'%lua_root]
 	c.env.INCLUDES_LUALIB   = ['%s/include'%lua_root]
 	c.env.LIB_LUALIB        = ['lua51']
 	c.env.LIBPATH_LUALIB    = ['%s/lib'%lua_root]