File: test_hooks.lua

package info (click to toggle)
monotone 0.31-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 20,680 kB
  • ctags: 14,801
  • sloc: cpp: 87,711; ansic: 64,862; sh: 5,691; lisp: 954; perl: 783; makefile: 509; python: 265; sql: 98; sed: 16
file content (137 lines) | stat: -rw-r--r-- 3,053 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

-- this is the "testing" set of lua hooks for monotone
-- it's intended to support self-tests, not for use in
-- production. just defines some of the std hooks.

function get_passphrase(keyid)
	return keyid
end

-- Everything alice signs is trusted, nothing mallory signs is
-- trusted.  For certs signed by other people, everything is
-- trusted except for one particular cert...
-- For use of t_trusted.at.
function get_revision_cert_trust(signers, id, name, val)
   for k, v in pairs(signers) do
      if v == "alice@trusted.com" then return true end
      if v == "mallory@evil.com" then return false end
   end
   if (id == "0000000000000000000000000000000000000000"
       and name == "bad-cert" and val == "bad-val")
   then return false end
   return true             
end

function get_manifest_cert_trust(signers, id, name, val)
   return true
end

function get_file_cert_trust(signers, id, name, val)
   return true
end

function accept_testresult_change(old_results, new_results)
   for test,res in pairs(old_results)
   do
      if res == true and new_results[test] ~= true
      then
	 return false
      end
   end
   return true
end

function persist_phrase_ok()
	return true
end

function get_author(branchname)
	return "tester@test.net"
end

function ignore_file(name)
	if (string.find(name, "ts-std", 1, true)) then return true end
	if (string.find(name, "testsuite.log")) then return true end
	if (string.find(name, "test_hooks.lua")) then return true end
	if (string.find(name, "keys")) then return true end
	return false
end

function merge2(left_path, right_path, merged_path, left, right)
	io.write("running merge2 hook\n") 
	return left
end

if (attr_functions == nil) then
  attr_functions = {}
end
attr_functions["test:test_attr"] =
  function(filename, value)
    io.write(string.format("test:test_attr:%s:%s\n", filename, value))
  end

function get_netsync_connect_command(uri, args)

	local argv = nil

	if uri["scheme"] == "ssh" 
		and uri["host"] 
		and uri["path"] then

		argv = { "ssh" }
		if uri["user"] then
			table.insert(argv, "-l")
			table.insert(argv, uri["user"])
		end
		if uri["port"] then
			table.insert(argv, "-p")
			table.insert(argv, uri["port"])
		end

		table.insert(argv, uri["host"])
	end
	
	if uri["scheme"] == "file" and uri["path"] then
		argv = { }
	end

	if argv then

		table.insert(argv, os.getenv("mtn"))

		if args["debug"] then
			table.insert(argv, "--debug")
		else
			table.insert(argv, "--quiet")
		end

		table.insert(argv, "--db")
		table.insert(argv, uri["path"])
		table.insert(argv, "serve")
		table.insert(argv, "--stdio")
		table.insert(argv, "--no-transport-auth")

		if args["include"] then
			table.insert(argv, args["include"])
		end

		if args["exclude"] then
			table.insert(argv, "--exclude")
			table.insert(argv, args["exclude"])
		end
	end
	return argv
end

function use_transport_auth(uri)
	if uri["scheme"] == "ssh" 
	or uri["scheme"] == "file" then
		return false
	else
		return true
	end
end

function get_encloser_pattern(name)
   return "^[[:alnum:]$_]"
end