# # # patch "lua-testsuite.lua" # from [d2db92ea969f6b5a4a7cd2d6a0dc6c528b41bbfa] # to [8c51a64689214ff32e375383879a1e921da58497] # # patch "tests/common/netsync.lua" # from [a33cf9951874259a390ad9ac0d9348893de4bac3] # to [6ed942e0e4b15d73e991b5a5cd9d0de420ed6576] # ============================================================ --- lua-testsuite.lua d2db92ea969f6b5a4a7cd2d6a0dc6c528b41bbfa +++ lua-testsuite.lua 8c51a64689214ff32e375383879a1e921da58497 @@ -1,7 +1,11 @@ monotone_path = nil #!./tester monotone_path = nil +testsuite_use_ws = false +-- If true, get as many options as possible from the workspace +-- _MTN/options; don't specify on command line + function safe_mtn(...) if monotone_path == nil then monotone_path = os.getenv("mtn") @@ -9,8 +13,14 @@ function safe_mtn(...) err("'mtn' environment variable not set") end end - return {monotone_path, "--norc", "--root=" .. test.root, - "--confdir="..test.root, unpack(arg)} + + if testsuite_use_ws then + -- FIXME: need to store confdir in _MTN/options + return {monotone_path, "--norc", unpack(arg)} + else + return {monotone_path, "--norc", "--root=" .. test.root, + "--confdir="..test.root, unpack(arg)} + end end -- function preexecute(x) @@ -26,10 +36,15 @@ function mtn(...) end function mtn(...) - return raw_mtn("--rcfile", test.root .. "/test_hooks.lua", -- "--nostd", - "--db=" .. test.root .. "/test.db", - "--keydir", test.root .. "/keys", - "address@hidden", unpack(arg)) + if testsuite_use_ws then + return raw_mtn ("--rcfile", test.root .. "/test_hooks.lua", unpack(arg)) + else + return raw_mtn("--rcfile", + test.root .. "/test_hooks.lua", + "--db=" .. test.root .. "/test.db", + "--keydir", test.root .. "/keys", + "address@hidden", unpack(arg)) + end end function nodb_mtn(...) @@ -77,10 +92,12 @@ function mtn_setup() check(getstd("test_keys")) check(getstd("test_hooks.lua")) check(getstd("min_hooks.lua")) - + + testsuite_use_ws = false check(mtn("db", "init"), 0, false, false) check(mtn("read", "test_keys"), 0, false, false) check(mtn("setup", "--branch=testbranch", "."), 0, false, false) + testsuite_use_ws = true remove("test_keys") end @@ -144,6 +161,7 @@ function revert_to(rev, branch, mt) remove("_MTN.old") rename("_MTN", "_MTN.old") + testsuite_use_ws = false check(mt("automate", "get_manifest_of", rev), 0, true, false) rename("stdout", "paths-old") @@ -153,7 +171,7 @@ function revert_to(rev, branch, mt) for path in io.lines("paths-new") do len = string.len(path) - 1 - + if (string.match(path, "^ file \"")) then path = string.sub(path, 10, len) elseif (string.match(path, "^dir \"")) then @@ -166,10 +184,10 @@ function revert_to(rev, branch, mt) remove(path) end end - + for path in io.lines("paths-old") do len = string.len(path) - 1 - + if (string.match(path, "^ file \"")) then path = string.sub(path, 10, len) elseif (string.match(path, "^dir \"")) then @@ -182,13 +200,14 @@ function revert_to(rev, branch, mt) remove(path) end end - + if branch == nil then check(mt("checkout", "--revision", rev, "."), 0, false, true) else check(mt("checkout", "--branch", branch, "--revision", rev, "."), 0, false, true) end check(base_revision() == rev) + testsuite_use_ws = true end function canonicalize(filename) @@ -209,7 +228,7 @@ function check_same_db_contents(db1, db2 function check_same_db_contents(db1, db2) check_same_stdout(mtn("--db", db1, "ls", "keys"), mtn("--db", db2, "ls", "keys")) - + check(mtn("--db", db1, "complete", "revision", ""), 0, true, false) rename("stdout", "revs") check(mtn("--db", db2, "complete", "revision", ""), 0, true, false) @@ -223,7 +242,7 @@ function check_same_db_contents(db1, db2 check_same_stdout(mtn("--db", db1, "automate", "get_manifest_of", rev), mtn("--db", db2, "automate", "get_manifest_of", rev)) end - + check(mtn("--db", db1, "complete", "file", ""), 0, true, false) rename("stdout", "files") check(mtn("--db", db2, "complete", "file", ""), 0, true, false) ============================================================ --- tests/common/netsync.lua a33cf9951874259a390ad9ac0d9348893de4bac3 +++ tests/common/netsync.lua 6ed942e0e4b15d73e991b5a5cd9d0de420ed6576 @@ -64,7 +64,10 @@ function netsync.start(opts, n, min) else table.insert(args, "--rcfile=netsync.lua") end - if n ~= nil then + if n == nil then + table.insert(args, "--keydir=keys") + table.insert(args, "--db=test.db") + else table.insert(args, "--keydir=keys"..n) table.insert(args, "--db=test"..n..".db") end