[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] How does 'mtn testresult' work?
From: |
Richard Hopkins |
Subject: |
Re: [Monotone-devel] How does 'mtn testresult' work? |
Date: |
Fri, 21 Dec 2012 19:24:06 +0000 (GMT) |
> cd ../testbranch2
> echo testkey2 > _MTN/wanted-testresults
> mtn update
> - ----- >8 -----
>
> I did expect that the last 'mtn update' would fail, since
> the first
> revision (99b505..) now contains a cert with name
> 'testresult' signed
> by testkey2 and value '1' while the second revision
> (a4bd7c..) has the
> same cert but with value '0'.
>
You are correct that the update should have failed as your workspace
revision "passes" and it's update target "fails". However, it seems
the default definition of 'accept_testresult_change' needs tweaking.
It's my understanding that 'wanted_testresults' should contain the key
hash for each of your test suite keys with 1 per line. The problem
is that the we pass the binary encoding of the hash instead of the
hex encoding. This will be resolved by the next release.
In the meantime you can workaround this issue by using the
default definition but hex encoding the keys beforehand in your
'_MTN/monotonerc'.
---<---
-- http://snippets.luacode.org/?p=snippets/String_to_Hex_String_68
function HexDumpString(str,spacer)
return (string.gsub(str,"(.)",
function (c)
return string.format("%02X%s",string.byte(c), spacer or "")
end)
)
end
function accept_testresult_change(old_results, new_results)
-- Hex encode each of the key hashes to match those in 'wanted-testresults'
local old_results_hex = {}
for k, v in pairs(old_results) do
old_results_hex[HexDumpString(k)] = v
end
local new_results_hex = {}
for k, v in pairs(new_results) do
new_results_hex[HexDumpString(k)] = v
end
local reqfile = io.open("_MTN/wanted-testresults", "r")
if (reqfile == nil) then return true end
local line = reqfile:read()
local required = {}
while (line ~= nil)
do
required[line] = true
line = reqfile:read()
end
io.close(reqfile)
for test, res in pairs(required)
do
if old_results_hex[test] == true and new_results_hex[test] ~= true
then
return false
end
end
return true
end
--->---