File: asttest.lua

package info (click to toggle)
asterisk-testsuite 0.0.0%2Bsvn.5781-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 18,632 kB
  • sloc: xml: 33,912; python: 32,904; ansic: 1,599; sh: 395; makefile: 170; sql: 17
file content (58 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- spawn the test driver and parse the results

module(..., package.seeall)

asttest = {}
function asttest:new(test_dir)
	local a = {
		dir = test_dir,
		tests = {},
		results = {},
		totals = {
			["pass"] = 0,
			["fail"] = 0,
			["xpass"] = 0,
			["xfail"] = 0,
			["skip"] = 0,
			["error"] = 0,
			["total"] = 0,
		},
	}
	setmetatable(a, self)
	self.__index = self
	return a
end

function asttest:parse_output()
	for test, result in string.gmatch(self.output, "%d+%.%s+(%S+)%s+(%S+)\n") do
		table.insert(self.tests, test)

		self.results[test] = result

		self.totals[result] = self.totals[result] + 1
		self.totals.total = self.totals.total + 1
	end
end

function asttest:spawn()
	local output = io.popen("../../asttest 2>&1 " .. self.dir)
	if not output then
		return true, "error running asttest"
	end

	self.log = self.dir .. "/asttest.log"
	self.output = output:read("*a")
	self:parse_output()
	return false
end

function run(dir)
	local a = asttest:new(dir)
	e, reason = a:spawn()
	if e then
		return nil
	else
		return a
	end
end