# # # add_file "tests/t_netsync_notes.at" # content [fe5855379bb052b21d11c429bbbc89eb495d5bac] # # patch "ChangeLog" # from [0b7921a9392278539f9f182ffc5fb0f96e30078a] # to [e2fd0804a517a3c62c2619e07fb1401d4c9c50ee] # # patch "testsuite.at" # from [6f568aca0c8fa9b3f72958f365dde4a6f37a8dd0] # to [f835201459609755bb331a16c0ee690865a4b84f] # ============================================================ --- tests/t_netsync_notes.at fe5855379bb052b21d11c429bbbc89eb495d5bac +++ tests/t_netsync_notes.at fe5855379bb052b21d11c429bbbc89eb495d5bac @@ -0,0 +1,95 @@ +# -*- Autoconf -*- + +AT_SETUP([exchanging work via netsync, with notes]) +AT_KEYWORDS([netsync]) + +MONOTONE_SETUP +NETSYNC_SETUP_WITH_NOTES + +AT_DATA(testfile, [version 0 of test file +]) +AT_CHECK(MONOTONE add testfile, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --branch=testbranch commit --message blah-blah, [], [ignore], [ignore]) +F_VER0=`SHA1(testfile)` +VER0=`BASE_REVISION` +MAN0=`BASE_MANIFEST` +DATE0=`CERTVALUE([$VER0],[date])` + +AT_DATA(testfile, [version 1 of test file +]) +AT_CHECK(MONOTONE commit --message blah-blah, [], [ignore], [ignore]) +F_VER1=`SHA1(testfile)` +VER1=`BASE_REVISION` +MAN1=`BASE_MANIFEST` +DATE1=`CERTVALUE([$VER1],[date])` + +RUN_NETSYNC(pull, testbranch) + +DATA(testnotes.test, +[start --------------------------------------------------- +revision: new_id = $VER0 +revision: revision = format_version "1" + +new_manifest m4_dquote($MAN0) + +old_revision m4_dquote([]) + +add_dir "" + +add_file "testfile" + content m4_dquote($F_VER0) + +revision: cert.name = branch +revision: cert.value = testbranch +revision: cert.key = address@hidden +revision: cert.name = changelog +revision: cert.value = blah-blah +revision: cert.key = address@hidden +revision: cert.name = date +revision: cert.value = $DATE0 +revision: cert.key = address@hidden +revision: cert.name = author +revision: cert.value = address@hidden +revision: cert.key = address@hidden +revision: new_id = $VER1 +revision: revision = format_version "1" + +new_manifest m4_dquote($MAN1) + +old_revision m4_dquote($VER0) + +patch "testfile" + from m4_dquote($F_VER0) + to m4_dquote($F_VER1) + +revision: cert.name = branch +revision: cert.value = testbranch +revision: cert.key = address@hidden +revision: cert.name = changelog +revision: cert.value = blah-blah +revision: cert.key = address@hidden +revision: cert.name = date +revision: cert.value = $DATE1 +revision: cert.key = address@hidden +revision: cert.name = author +revision: cert.value = address@hidden +revision: cert.key = address@hidden +end ----------------------------------------------------- +]) +AT_CHECK(cmp testnotes.log testnotes.test, [0], [ignore], [ignore]) + +AT_CHECK(MONOTONE tag $VER0 testtag, [], [ignore], [ignore]) + +RUN_NETSYNC(pull, testbranch) + +DATA(testnotes.test, +[start --------------------------------------------------- +cert: rev_id = $VER0 +cert: name = tag +cert: value = testtag +cert: key = address@hidden +end ----------------------------------------------------- +]) +AT_CHECK(cmp testnotes.log testnotes.test, [0], [ignore], [ignore]) + +AT_CLEANUP ============================================================ --- ChangeLog 0b7921a9392278539f9f182ffc5fb0f96e30078a +++ ChangeLog e2fd0804a517a3c62c2619e07fb1401d4c9c50ee @@ -1,5 +1,21 @@ 2006-03-17 Richard Levitte + * tests/t_netsync_notes.at: New test to check that the + note_netsync hooks work as they should. + * testsuite.at: Add the above test as well as the following + useful macros. + (BASE_MANIFEST): Gives the manifest identity of the base + revision. + (WORKING_MANIFEST): Gives the manifest identity of the workspace. + (CERTVALUE): Picks out the value of a specific cert from a given + revision. + (DATA): Like AT_DATA, but allows environment variables to be + expanded in the resulting file. + (NETSYNC_SETUP_WITH_NOTES): A variant of NETSYNC_SETUP that adds + note_netsync hooks. + +2006-03-17 Richard Levitte + * lua.cc, lua.hh (lua::hookshook_note_netsync_revision_received, lua::hookshook_note_netsync_cert_received, lua::hookshook_note_netsync_pubkey_received): Change them so nonce ============================================================ --- testsuite.at 6f568aca0c8fa9b3f72958f365dde4a6f37a8dd0 +++ testsuite.at f835201459609755bb331a16c0ee690865a4b84f @@ -20,13 +20,30 @@ m4_define([MINHOOKS_MONOTONE], [$PREEXECUTE $_MT_EXEC --db=$_ROOT_DIR/test.db --keydir=$_ROOT_DIR/keys --rcfile=$_ROOT_DIR/min_hooks.lua address@hidden --root=$_ROOT_DIR]) m4_define([SHA1], [monotone --norc identify $1]) m4_define([BASE_REVISION], [cat MT/revision]) +m4_define([BASE_MANIFEST], [cat MT/revision | monotone --norc automate get_manifest_of address@hidden | monotone --norc identify]) m4_define([WORKING_REVISION], [monotone --norc automate get_revision | monotone --norc identify]) +m4_define([WORKING_MANIFEST], [monotone --norc automate get_manifest_of | monotone --norc identify]) +m4_define([CERTVALUE], [monotone automate certs $1 | sed -e '1,/name "$2"/d' | sed -e '/^$/,$d' | grep '^ *value' | sed -e 's/^m4_dquote([^"])*"//' -e 's/"m4_dquote([^"])*$//']) m4_define([CANONICALISE], [ if test "$OSTYPE" = "msys"; then dos2unix -q -o $1 fi ]) +# DATA(FILE, CONTENTS) +# -------------------- +# Initialize an input data FILE with given CONTENTS, which should end with +# an end of line. +# This macro is not robust to active symbols or environment variable +# expansion in CONTENTS *on purpose*. +# If you don't want CONTENTS to be evaluated, quote it twice. +# If you don't want environment variables in CONTENTS to be expanded, +# escape all dollar signs, or use AT_DATA. +m4_define([DATA], +[cat >$1 <<_ATEOF +$2[]_ATEOF +]) + # the MONOTONE_SETUP macro deploys the standard lua hooks and loads the # standard testing key, which we use for further tests. @@ -362,6 +379,54 @@ ]) +m4_define([NETSYNC_SETUP_WITH_NOTES], [ +NETSYNC_SETUP + +AT_DATA(netsync.lua, [ +logfile = nil + +function note_netsync_start() + logfile = io.open("testnotes.log","w") + logfile:write("start ---------------------------------------------------\n") +end + +function note_netsync_revision_received(new_id, revision, certs) + logfile:write("revision: new_id = " .. new_id .. "\n") + logfile:write("revision: revision = " .. revision .. "\n") + for i, cert in pairs(certs) + do + logfile:write("revision: cert.name = " .. cert.name .. "\n") + logfile:write("revision: cert.value = " .. cert.value .. "\n") + logfile:write("revision: cert.key = " .. cert.key .. "\n") + end +end + +function note_netsync_cert_received(rev_id, key, name, value) + logfile:write("cert: rev_id = " .. rev_id .. "\n") + logfile:write("cert: name = " .. name .. "\n") + logfile:write("cert: value = " .. value .. "\n") + logfile:write("cert: key = " .. key .. "\n") +end + +function note_netsync_pubkey_received(keyname) + logfile:write("pubkey: " .. keyname .. "\n") +end + +function note_netsync_end() + logfile:write("end -----------------------------------------------------\n") + logfile:close() +end + +function get_netsync_read_permitted(pattern, identity) + return true +end + +function get_netsync_write_permitted(identity) + return true +end +]) +]) + m4_define([MONOTONE2], MONOTONE --db=test2.db --keydir=keys2) m4_define([MONOTONE3], MONOTONE --db=test3.db --keydir=keys3) @@ -796,3 +861,4 @@ m4_include(tests/t_sink_has_extra_epochs.at) m4_include(tests/t_disapprove_branch.at) m4_include(tests/t_serve_ignores_mt_options.at) +m4_include(tests/t_netsync_notes.at)