# # # patch "testlib.lua" # from [44d6be1881e02da1a2bb908a99f995f1d0af4830] # to [0e8c0415f85924dfb385a6e6a0de8b0f787a611d] # # patch "tests/automate_inventory/__driver__.lua" # from [3dfb9ba03b255abf9470e6242d016f98fc4b4429] # to [2e9f9f2eed991ec9008d79eba023e2d634c0191e] # # patch "tests/automate_inventory_ignore_dirs/expected.stderr" # from [5a2123381f2129c6ea4b4a2646a35da60663d635] # to [8d34d463808ddf9b868d0e415a571ff18002388b] # # patch "tests/automate_inventory_ignore_dirs/expected_2.stderr" # from [139fa2659365d1899a757ff8ef6191e6263064fe] # to [9937d25da7c3bd55a10ba16018fade6ee9562e92] # # patch "tests/automate_inventory_restricted/__driver__.lua" # from [727c314a4b0ed6b29354a650e2f7721f4d753fc0] # to [ffb529f5c0632466857eaa24848d39e1cc1577d6] # # patch "tests/db_data_format_checking/__driver__.lua" # from [e3f5be2451252d0c52a609f638c402ac8a9cf302] # to [c675dbc20a827bb32bd02719a3223e0a0e4001ad] # # patch "tests/non_workspace_keydir/__driver__.lua" # from [f52253b52aee3988a6fd95920fff44c8e943b004] # to [42fd41dbdf35be5288d60cb2e3ac589770cb83e9] # # patch "tests/pid_file_and_log_handles_open_failures/__driver__.lua" # from [1da5c1056509a1fa78b7492e9e9100228b8661f6] # to [9d10776466ab4ab193466e45a156a63f60491553] # # patch "tests/syntax_errors_in_.mtn-ignore/stdout-ref" # from [98b118d4a2e3bd4f52dcbe7c790a70f1b52aa901] # to [35ddfeda5089ea016cb0713fea9201fd00b5520b] # # patch "tests/two_parent_workspace_list/__driver__.lua" # from [65c50373573076490512bf8852e35bb671f34ff7] # to [5d6df31659e888cf21e541121d487d3e5249e2df] # ============================================================ --- testlib.lua 44d6be1881e02da1a2bb908a99f995f1d0af4830 +++ testlib.lua 0e8c0415f85924dfb385a6e6a0de8b0f787a611d @@ -1061,6 +1061,16 @@ function run_one_test(tname) test.bglist = {} test.log = io.open("tester.log", "w") + -- Sanitize $HOME. This is done here so that each test gets its + -- very own empty directory (in case some test writes stuff inside). + unlogged_mkdir("emptyhomedir") + test.home = test.root .. "/emptyhomedir" + if ostype == "Windows" then + set_env("APPDATA", test.home) + else + set_env("HOME", test.home) + end + L("Test ", test.name, "\n") local driverfile = testdir .. "/" .. test.name .. "/__driver__.lua" ============================================================ --- tests/automate_inventory/__driver__.lua 3dfb9ba03b255abf9470e6242d016f98fc4b4429 +++ tests/automate_inventory/__driver__.lua 2e9f9f2eed991ec9008d79eba023e2d634c0191e @@ -64,6 +64,11 @@ index = check_inventory (parsed, index, status = "dropped"}) index = check_inventory (parsed, index, +{ path = "emptyhomedir", + fs_type = "directory", + status = "unknown"}) + +index = check_inventory (parsed, index, { path = "ignored~", fs_type = "file", status = "ignored"}) ============================================================ --- tests/automate_inventory_ignore_dirs/expected.stderr 5a2123381f2129c6ea4b4a2646a35da60663d635 +++ tests/automate_inventory_ignore_dirs/expected.stderr 8d34d463808ddf9b868d0e415a571ff18002388b @@ -1,3 +1,4 @@ +ignore_file: 'emptyhomedir': false ignore_file: 'keys': false ignore_file: 'source': false ignore_file: 'source/ignored_dir': true ============================================================ --- tests/automate_inventory_ignore_dirs/expected_2.stderr 139fa2659365d1899a757ff8ef6191e6263064fe +++ tests/automate_inventory_ignore_dirs/expected_2.stderr 9937d25da7c3bd55a10ba16018fade6ee9562e92 @@ -1,3 +1,4 @@ +ignore_file: 'emptyhomedir': false ignore_file: 'keys': false ignore_file: 'source': false ignore_file: 'source/ignored_dir': true ============================================================ --- tests/automate_inventory_restricted/__driver__.lua 727c314a4b0ed6b29354a650e2f7721f4d753fc0 +++ tests/automate_inventory_restricted/__driver__.lua ffb529f5c0632466857eaa24848d39e1cc1577d6 @@ -74,6 +74,11 @@ index = check_inventory (parsed, index, status = {"known"}}) index = check_inventory (parsed, index, +{ path = "emptyhomedir", + fs_type = "directory", + status = "unknown"}) + +index = check_inventory (parsed, index, { path = "file_0", old_type = "file", new_type = "file", @@ -116,6 +121,11 @@ index = check_inventory (parsed, index, status = {"known"}}) index = check_inventory (parsed, index, +{ path = "emptyhomedir", + fs_type = "directory", + status = "unknown"}) + +index = check_inventory (parsed, index, { path = "file_0", old_type = "file", new_type = "file", @@ -302,6 +312,11 @@ index = check_inventory (parsed, index, status = {"known"}}) index = check_inventory (parsed, index, +{ path = "emptyhomedir", + fs_type = "directory", + status = "unknown"}) + +index = check_inventory (parsed, index, { path = "file_0", old_type = "file", new_path = "dir_a/file_0", @@ -349,6 +364,11 @@ index = check_inventory (parsed, index, status = {"known"}}) index = check_inventory (parsed, index, +{ path = "emptyhomedir", + fs_type = "directory", + status = "unknown"}) + +index = check_inventory (parsed, index, { path = "file_0", old_type = "file", new_path = "dir_a/file_0", ============================================================ --- tests/db_data_format_checking/__driver__.lua e3f5be2451252d0c52a609f638c402ac8a9cf302 +++ tests/db_data_format_checking/__driver__.lua c675dbc20a827bb32bd02719a3223e0a0e4001ad @@ -13,7 +13,7 @@ check(mtn("-d", "cs-modern.db", "ls", "k check(mtn("-d", "cs-modern.db", "db", "migrate"), 0, false, false) check(mtn("-d", "cs-modern.db", "ls", "keys"), 1, false, false) -check(mtn("-d", "cs-modern.db", "serve", "--bind=127.0.0.1:63219"), 1, false, false) +check(mtn("-d", "cs-modern.db", "ls", "branches"), 1, false, false) check(get("rosterify.db.dumped", "stdin")) @@ -21,7 +21,7 @@ check(mtn("-d", "ro-modern.db", "ls", "k check(mtn("-d", "ro-modern.db", "db", "migrate"), 0, false, false) check(mtn("-d", "ro-modern.db", "ls", "keys"), 1, false, false) -check(mtn("-d", "ro-modern.db", "serve", "--bind=127.0.0.1:63219"), 1, false, false) +check(mtn("-d", "ro-modern.db", "ls", "branches"), 1, false, false) -- arguably "db regenerate_caches" should go here too -- it's treated -- similarly. But the test "schema_migration" tests for its behavior in this ============================================================ --- tests/non_workspace_keydir/__driver__.lua f52253b52aee3988a6fd95920fff44c8e943b004 +++ tests/non_workspace_keydir/__driver__.lua 42fd41dbdf35be5288d60cb2e3ac589770cb83e9 @@ -1,5 +1,3 @@ -mtn_setup() - -- adapted from lua-testsuite.lua mtn; no --confdir, --keydir, or --key function pure_mtn(...) if monotone_path == nil then @@ -8,59 +6,40 @@ function pure_mtn(...) err("'mtn' environment variable not set") end end - return {monotone_path, "--ssh-sign=no", "--norc", "--root=" .. test.root, "--db", "test.db", - "--rcfile", test.root .. "/test_hooks.lua", unpack(arg)} + return {monotone_path, "--ssh-sign=no", "--norc", + "--root=" .. test.root, "--db", "test.db", + "--rcfile", test.root .. "/test_hooks.lua", unpack(arg)} end --- this should find a private key in the specified keydir +mtn_setup() --- On Unix, the return code from the background process is the signal --- value; srv:finish sends signal -15 to stop the process. Not so on --- Windows. +addfile("file", "contents") +commit() +rev = base_revision() --- However, this means we need to check stderr from the background --- command to check for success or failure. +-- make test.root not a workspace anymore +check(rename("_MTN", "not_MTN")) -if ostype == "Windows" then -expected_ret = 1 -else -expected_ret = -15 -end +-- this should fail to find any private key to sign the cert with +check(pure_mtn("cert", rev, "fail1", "value"), + 1, nil, true) +check(qgrep("you have no private key", "stderr")) --- some random address, code stolen from netsync.lua -addr = "localhost:" .. math.random(1024, 65535) -srv = bg(pure_mtn("serve", "--bind="..addr, "--confdir="..test.root, "--keydir="..test.root.."/keys"), expected_ret, false, true) -sleep(2) -srv:finish() -check(qgrep("beginning service", "stderr")) +-- this should find a private key in the keys directory under the +-- specified confdir +check(pure_mtn("--confdir="..test.root, + "cert", rev, "test1", "value"), + 0, nil, nil) --- this should find a private key in the keys directory under the specified confdir +-- this should fail to find a private key, since there is no +-- keys subdirectory of this directory +check(pure_mtn("--confdir="..test.home, + "cert", rev, "fail2", "value"), + 1, nil, true) +check(qgrep("you have no private key", "stderr")) +-- this should find a private key in the specified keydir +check(pure_mtn("--confdir="..test.home, "--keydir="..test.root.."/keys", + "cert", rev, "test2", "value"), + 0, nil, nil) -srv = bg(pure_mtn("serve", "--bind="..addr, "--confdir="..test.root), expected_ret, false, true) -sleep(2) -srv:finish() -check(qgrep("beginning service", "stderr")) - --- this should fail to decrypt the private key found in ~/.monotone/keys - --- however before get_default_keydir was added to the key_dir option in --- options_list.hh it would hit an invariant on an empty key_dir for any --- CMD_NO_WORKSPACE that attempted to call get_user_key(...) - --- The expected return value is the same on Unix and Windows - -mkdir(test.root.."/empty") --- FIXME: this should probably be set globally in lua-testsuite.lua for --- all tests. -if ostype == "Windows" then -set_env("APPDATA", test.root.."/empty") -else -set_env("HOME", test.root.."/empty") -end -srv = bg(pure_mtn("serve", "--bind="..addr), 1, false, true) -sleep(2) -srv:finish() -check(qgrep("misuse: you have no private key", "stderr")) - --- end of file ============================================================ --- tests/pid_file_and_log_handles_open_failures/__driver__.lua 1da5c1056509a1fa78b7492e9e9100228b8661f6 +++ tests/pid_file_and_log_handles_open_failures/__driver__.lua 9d10776466ab4ab193466e45a156a63f60491553 @@ -22,9 +22,13 @@ else check({"chmod", "100", "noaccess"}) check(mtn("--log=noaccess/my.log", "status"), 1, false, false) - srv = bg(mtn("serve", "--bind=127.0.0.2:55597", "--pid-file=noaccess/my.pid"), 1, false, false) - + -- we use --stdio here to avoid the possibility of the pidfile being + -- created and then the test tripping over network restrictions. + srv = bg(mtn("serve", "--stdio", "--pid-file=noaccess/my.pid"), + 1, nil, true, nil) + check(srv:wait(5)) + check(qgrep("failed to create pid file", "stderr")) end remove("noaccess") ============================================================ --- tests/syntax_errors_in_.mtn-ignore/stdout-ref 98b118d4a2e3bd4f52dcbe7c790a70f1b52aa901 +++ tests/syntax_errors_in_.mtn-ignore/stdout-ref 35ddfeda5089ea016cb0713fea9201fd00b5520b @@ -1,5 +1,6 @@ dontignoreme .mtn-ignore dontignoreme +emptyhomedir keys min_hooks.lua test_hooks.lua ============================================================ --- tests/two_parent_workspace_list/__driver__.lua 65c50373573076490512bf8852e35bb671f34ff7 +++ tests/two_parent_workspace_list/__driver__.lua 5d6df31659e888cf21e541121d487d3e5249e2df @@ -31,7 +31,7 @@ check(mtn("ls", "ignored"), 0, "keys\nte -- subdirectory for the workspace (and therefore to keep it cleaner) -- or to ignore them all properly, this will have to change. check(mtn("ls", "ignored"), 0, "keys\ntest.db\ntest_hooks.lua\nts-stderr\nts-stdin\nts-stdout\n", nil) -check(mtn("ls", "unknown"), 0, "_MTN.old\nmin_hooks.lua\npaths-new\npaths-old\nstderr\ntester.log\n", nil) +check(mtn("ls", "unknown"), 0, "_MTN.old\nemptyhomedir\nmin_hooks.lua\npaths-new\npaths-old\nstderr\ntester.log\n", nil) -- we do this after the other tests so it doesn't interfere with them. remove("file4")