monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: a0ed177b60caee5cf304c01d83e


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: a0ed177b60caee5cf304c01d83e75812af1225e1
Date: Tue, 24 Apr 2012 22:12:04 +0200 (CEST)

revision:            a0ed177b60caee5cf304c01d83e75812af1225e1
date:                2012-04-24T20:11:49
author:              address@hidden
branch:              net.venge.monotone
changelog:
* test/src/testlib.lua: add functions url_encode_{path,query} to
  escape the corresponding part of a URI.
* test/func/*/__driver__.lua: make proper use of these new escaping
  functions to be able to run the test suite under a path that
  includes i.e. a plus sign.
* test/func/util_mtnopt/__driver__.lua: special testroot escaping for
  (q)grep to make that test work under paths with plus signs.

manifest:
format_version "1"

new_manifest [a1c7cfbf844e44082fad049e735563108fcd6214]

old_revision [9d8072b394d0f9dd44167d491c8abc8fac054755]

patch "test/func/attr_mtn_execute/__driver__.lua"
 from [ac0c1f7ecf54690607e55d5aa43544c023e3700c]
   to [b5bfcf8f4fdb98c59f95da35b93e7d97d08b99e7]

patch "test/func/branch_leaves_sync_bug/__driver__.lua"
 from [6b227867aeb3692dba4e68efdfe5c59ff5c15919]
   to [943c3f2d7c3294e5da221d44911c08511058acb2]

patch "test/func/clone_aborts_on_branch_pattern_in_uri/__driver__.lua"
 from [bf16d8dcec86e4ae012d1c6078082f9d13a9fd80]
   to [e75946886b2b0b4ee301016860238e6315c22a59]

patch "test/func/clone_branch_no_dir/__driver__.lua"
 from [b490cd593cefd9aa0b4dec9ab177eb72c3fb8058]
   to [1ab33d8f6d1bdc38d3804d8fcd41b6c2f65a6e61]

patch "test/func/clone_creates__MTN_log/__driver__.lua"
 from [5a8fe703d56ea39db22dcfbe6183294c1eb3f01b]
   to [b412d2f37df048846fc1f76ab62572d4c39b0796]

patch "test/func/clone_creates_right__MTN_options/__driver__.lua"
 from [12e86831366aa0f5573d1ec511872b6f9034aeb2]
   to [9891e77e30b8830f8040bcb817a0db26a433c9dd]

patch "test/func/clone_validates_target_directory/__driver__.lua"
 from [1286723ee00ea9ea6831e12575ba7ac32a066645]
   to [0c6f70282431ed62359ad0b4a827575406889f4b]

patch "test/func/clone_warning_with_multiple_heads/__driver__.lua"
 from [4333c6de0518517ff9bc04b4baef0d2d5ff08914]
   to [18e8670ea08dcb9602425ebdb97a786b20945ff6]

patch "test/func/clone_weird_branch_names/__driver__.lua"
 from [205c20a2809513b93ee9ab6c1affb24070f284a2]
   to [0afc1816afa8d3e4b2dfb9fd016500f224432f0a]

patch "test/func/imp_test_filesync_confdir/__driver__.lua"
 from [5262dae96bcf38a2a27cea3d17523e08ad3e03aa]
   to [19822aa249d9300dc8695f41adbd12cbce5a9234]

patch "test/func/netsync_over_pipes/__driver__.lua"
 from [e4ee774912c36ca34a2bfe897daecac570f626a7]
   to [e769e909c59f15351c957a47d98bd7be5868e9f7]

patch "test/func/serve-automate/__driver__.lua"
 from [ae4b03baf16d8401f31a32c8377021f879788d01]
   to [1343490c3b79e3d936a5b72ba7561055239235f8]

patch "test/func/serve-automate-single-run/__driver__.lua"
 from [01013ad10150f9056bee7609338cb09b47d8c677]
   to [7a75e9ff02a15ebc62a44c1c596ed39e3fdae0a0]

patch "test/func/util_mtnopt/__driver__.lua"
 from [84307ea94ec302c6d9bbe163955e8f5e86973ce0]
   to [6981b9fe1aa7800aaaf76bd18f0ddbb73b0e6046]

patch "test/src/testlib.lua"
 from [6d2a308918594226fa6549ed0268ccaea3921038]
   to [f236da6fce62c15acac578b42756b552e0453d99]
============================================================
--- test/src/testlib.lua	6d2a308918594226fa6549ed0268ccaea3921038
+++ test/src/testlib.lua	f236da6fce62c15acac578b42756b552e0453d99
@@ -144,6 +144,22 @@ end
   return n
 end
 
+-- encodes a query by percent escaping reserved characters (as defined
+-- in RFC 3986) - except for the directory separator ('/').
+function url_encode_path(path)
+  path = string.gsub(path, "([!*'();:@&=+$,?#[%]])",
+    function (x) return string.format("%%%02X", string.byte(x)) end)
+  return string.gsub(path, " ", "+")
+end
+
+-- encodes a query by percent escaping reserved characters (as defined
+-- in RFC 3986) - except for the ampersand and equal sign ('&', '=')
+function url_encode_query(path)
+  path = string.gsub(path, "([!*'();:@+$,/?#[%]])",
+    function (x) return string.format("%%%02X", string.byte(x)) end)
+  return string.gsub(path, " ", "+")
+end
+
 function open_or_err(filename, mode, depth)
   local file, e = io.open(filename, mode)
   if file == nil then
============================================================
--- test/func/netsync_over_pipes/__driver__.lua	e4ee774912c36ca34a2bfe897daecac570f626a7
+++ test/func/netsync_over_pipes/__driver__.lua	e769e909c59f15351c957a47d98bd7be5868e9f7
@@ -7,6 +7,7 @@ commit()
 addfile("testfile", "foo")
 commit()
 
-check(mtn("sync", "file://" .. test.root .. "/test2.db?testbranch"), 0, false, true)
+test_uri="file://" .. url_encode_path(test.root .. "/test2.db") .. "?testbranch"
+check(mtn("sync", test_uri), 0, false, true)
 check(not qgrep("error", "stderr"))
 check_same_db_contents("test.db", "test2.db")
============================================================
--- test/func/clone_branch_no_dir/__driver__.lua	b490cd593cefd9aa0b4dec9ab177eb72c3fb8058
+++ test/func/clone_branch_no_dir/__driver__.lua	1ab33d8f6d1bdc38d3804d8fcd41b6c2f65a6e61
@@ -6,18 +6,18 @@ copy("test.db", "test-clone.db")
 commit("mybranch")
 
 copy("test.db", "test-clone.db")
-testURI="file://" .. test.root .. "/test-clone.db?mybranch"
 
-check(nodb_mtn("clone", testURI), 0, false, false)
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?mybranch"
+check(nodb_mtn("clone", test_uri), 0, false, false)
 check(exists("mybranch"))
 check(readfile("foo") == readfile("mybranch/foo"))
 
 -- but now that that directory exists, this clone should fail
-check(nodb_mtn("clone", testURI), 1, false, false)
+check(nodb_mtn("clone", test_uri), 1, false, false)
 
 -- but succeed if given a specific dir
-check(nodb_mtn("clone", testURI, "otherdir"), 0, false, false)
+check(nodb_mtn("clone", test_uri, "otherdir"), 0, false, false)
 
 -- clone into . should not fail, like checkout
 mkdir("test4")
-check(indir("test4", nodb_mtn("clone", testURI, ".")), 0, false, false)
+check(indir("test4", nodb_mtn("clone", test_uri, ".")), 0, false, false)
============================================================
--- test/func/clone_creates__MTN_log/__driver__.lua	5a8fe703d56ea39db22dcfbe6183294c1eb3f01b
+++ test/func/clone_creates__MTN_log/__driver__.lua	b412d2f37df048846fc1f76ab62572d4c39b0796
@@ -13,9 +13,9 @@ copy("test.db", "test-clone.db")
 check(mtn("--branch=testbranch", "--rcfile=commit_log.lua", "commit"), 0, false, false)
 
 copy("test.db", "test-clone.db")
-testURI="file://" .. test.root .. "/test-clone.db?testbranch"
 
-check(nodb_mtn("clone", testURI, "testbranch"), 0, false, true)
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?testbranch"
+check(nodb_mtn("clone", test_uri, "testbranch"), 0, false, true)
 
 check(exists("testbranch/_MTN/log"))
 check(fsize("_MTN/log") == 0)
============================================================
--- test/func/clone_creates_right__MTN_options/__driver__.lua	12e86831366aa0f5573d1ec511872b6f9034aeb2
+++ test/func/clone_creates_right__MTN_options/__driver__.lua	9891e77e30b8830f8040bcb817a0db26a433c9dd
@@ -10,7 +10,7 @@ commit()
 writefile("testfile", "blah")
 commit()
 
-testURI="file://" .. test.root .. "/test-clone.db?testbranch"
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?testbranch"
 
 -- We use RAW_MTN because it used to be that passing --db= (as
 -- MTN does) would hide a bug in this functionality...
@@ -18,16 +18,17 @@ testURI="file://" .. test.root .. "/test
 -- all of these inherit options settings from the current _MTN dir
 -- unless they override them on the command line
 
-check(nodb_mtn("clone", testURI, "test_dir1"), 0, false, false)
-check(nodb_mtn("clone", "--revision", rev, testURI, "test_dir2"), 0, false, false)
-check(nodb_mtn("--db=" .. test.root .. "/test-new.db", "clone", testURI, "test_dir3"), 0, false, false)
-check(nodb_mtn("--db=" .. test.root .. "/test-new.db", "clone", testURI, "--revision", rev, "test_dir4"), 0, false, false)
+check(nodb_mtn("clone", test_uri, "test_dir1"), 0, false, false)
+check(nodb_mtn("clone", "--revision", rev, test_uri, "test_dir2"), 0, false, false)
+check(nodb_mtn("--db=" .. test.root .. "/test-new.db", "clone", test_uri, "test_dir3"), 0, false, false)
+check(nodb_mtn("--db=" .. test.root .. "/test-new.db", "clone", test_uri, "--revision", rev, "test_dir4"), 0, false, false)
 
 -- checkout fails if the specified revision is not a member of the specified branch
-testURI="file://" .. test.root .. "/test-clone.db?foobar"
-check(nodb_mtn("clone", testURI, "--revision", rev, "test_dir5"), 1, false, false)
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?foobar"
+
+check(nodb_mtn("clone", test_uri, "--revision", rev, "test_dir5"), 1, false, false)
 check(nodb_mtn("cert", rev, "branch", "foobar", "-d", "test-clone.db"), 0, false, false)
-check(nodb_mtn("clone", testURI, "--revision", rev, "test_dir6"), 0, false, false)
+check(nodb_mtn("clone", test_uri, "--revision", rev, "test_dir6"), 0, false, false)
 
 
 for i = 1,2 do
============================================================
--- test/func/clone_validates_target_directory/__driver__.lua	1286723ee00ea9ea6831e12575ba7ac32a066645
+++ test/func/clone_validates_target_directory/__driver__.lua	0c6f70282431ed62359ad0b4a827575406889f4b
@@ -6,15 +6,15 @@ copy("test.db", "test-clone.db")
 commit()
 
 copy("test.db", "test-clone.db")
-testURI="file://" .. test.root .. "/test-clone.db?testbranch"
 
-check(nodb_mtn("clone", testURI, "test_dir1"), 0, false, false)
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?testbranch"
+check(nodb_mtn("clone", test_uri, "test_dir1"), 0, false, false)
 
 writefile("test_dir2")
-check(nodb_mtn("clone", testURI, "test_dir2"), 1, false, false)
+check(nodb_mtn("clone", test_uri, "test_dir2"), 1, false, false)
 
 mkdir("test_dir3")
-check(nodb_mtn("clone", testURI, "test_dir3"), 1, false, false)
+check(nodb_mtn("clone", test_uri, "test_dir3"), 1, false, false)
 
 if existsonpath("chmod") and existsonpath("test") then
   -- skip this part if run as root (hi Gentoo!)
@@ -27,9 +27,9 @@ if existsonpath("chmod") and existsonpat
   else
     mkdir("test_dir4")
     check({"chmod", "444", "test_dir4"}, 0, false)
-    check(nodb_mtn("clone", testURI, "test_dir4"),
+    check(nodb_mtn("clone", test_uri, "test_dir4"),
              1, false, false)
-    check(nodb_mtn("clone", testURI, "test_dir4/subdir"),
+    check(nodb_mtn("clone", test_uri, "test_dir4/subdir"),
              1, false, false)
     -- Reset the permissions so Autotest can correctly clean up our
     -- temporary directory.
============================================================
--- test/func/clone_warning_with_multiple_heads/__driver__.lua	4333c6de0518517ff9bc04b4baef0d2d5ff08914
+++ test/func/clone_warning_with_multiple_heads/__driver__.lua	18e8670ea08dcb9602425ebdb97a786b20945ff6
@@ -16,9 +16,9 @@ copy("test.db", "test-clone.db")
 REV3=base_revision()
 
 copy("test.db", "test-clone.db")
-testURI="file://" .. test.root .. "/test-clone.db?testbranch"
 
-check(nodb_mtn("clone", testURI, "test_dirA"),
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?testbranch"
+check(nodb_mtn("clone", test_uri, "test_dirA"),
          1, false, true)
 check(qgrep(REV2, "stderr"))
 check(qgrep(REV3, "stderr"))
============================================================
--- test/func/imp_test_filesync_confdir/__driver__.lua	5262dae96bcf38a2a27cea3d17523e08ad3e03aa
+++ test/func/imp_test_filesync_confdir/__driver__.lua	19822aa249d9300dc8695f41adbd12cbce5a9234
@@ -18,7 +18,8 @@ end
    rcfile:close()
 end
 
-check(mtn("sync", "file://" .. test.root .. "/test2.db?testbranch"), 0, true, false)
+test_uri="file://" .. url_encode_path(test.root .. "/test2.db") .. "?testbranch"
+check(mtn("sync", test_uri), 0, true, false)
 
 n = 0
 
============================================================
--- test/func/util_mtnopt/__driver__.lua	84307ea94ec302c6d9bbe163955e8f5e86973ce0
+++ test/func/util_mtnopt/__driver__.lua	6981b9fe1aa7800aaaf76bd18f0ddbb73b0e6046
@@ -6,6 +6,11 @@ normalized_testroot = normalize_path (te
 
 normalized_testroot = normalize_path (test.root)
 
+-- Escape regexp special characters to form a proper regexp that correctly
+-- checks for the given path.
+escaped_testroot = string.gsub(normalized_testroot, "([*+.()[\\^$|?])",
+  function (x) return "\\" .. x end)
+
 -- check default operation
 
 -- MinGW does not process the shebang in mtnopt; must invoke sh directly
@@ -13,7 +18,7 @@ check({"sh", "./mtnopt"}, 0, true)
 -- Don't pass the full /bin/sh path, it looks like that doesn't always
 -- work under mingw.
 check({"sh", "./mtnopt"}, 0, true)
-check(qgrep('^MTN_database="' .. normalized_testroot .. '/test.db";$', "stdout"))
+check(qgrep('^MTN_database="' .. escaped_testroot .. '/test.db";$', "stdout"))
 check(qgrep('^MTN_branch="testbranch";$', "stdout"))
 
 -- check operation with a specific key and just returning the value
============================================================
--- test/func/attr_mtn_execute/__driver__.lua	ac0c1f7ecf54690607e55d5aa43544c023e3700c
+++ test/func/attr_mtn_execute/__driver__.lua	b5bfcf8f4fdb98c59f95da35b93e7d97d08b99e7
@@ -30,7 +30,7 @@ copy("test.db", "test-clone.db")
 -- test clone with mtn:execute
 
 copy("test.db", "test-clone.db")
-testURI="file://" .. test.root .. "/test-clone.db?testbranch"
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?testbranch"
 
-check(nodb_mtn("clone", testURI, "clone"), 0, false, true)
+check(nodb_mtn("clone", test_uri, "clone"), 0, false, true)
 check(indir("clone", {"test", "-x","foo"}, 0, false, false))
============================================================
--- test/func/serve-automate/__driver__.lua	ae4b03baf16d8401f31a32c8377021f879788d01
+++ test/func/serve-automate/__driver__.lua	1343490c3b79e3d936a5b72ba7561055239235f8
@@ -56,7 +56,8 @@ if ostype ~= "Windows" then
 if ostype ~= "Windows" then
 -- 'file:' not supported on Windows
 
-check(mtn2("automate", "remote_stdio", "file://" .. test.root .. "/test.db"),
+test_uri="file://" .. url_encode_path(test.root .. "/test.db")
+check(mtn2("automate", "remote_stdio", test_uri),
       0, true, false, "l17:interface_versione")
 check(parse_stdio(readfile("stdout"), 0, 0, "m") ~= nil)
 end
============================================================
--- test/func/serve-automate-single-run/__driver__.lua	01013ad10150f9056bee7609338cb09b47d8c677
+++ test/func/serve-automate-single-run/__driver__.lua	7a75e9ff02a15ebc62a44c1c596ed39e3fdae0a0
@@ -60,8 +60,9 @@ copy("allow-automate.lua", "custom_test_
 -- 'file:' not supported on Windows
 
 copy("allow-automate.lua", "custom_test_hooks.lua")
+test_uri="file://" .. url_encode_path(test.root .. "/test.db")
 check(mtn2("automate", "remote", "--remote-stdio-host",
-	   "file://"..test.root.."/test.db",
+	   test_uri,
 	   "get_file_of", "--", "-r".. R1, "foo"), 0, true, false)
 check(qgrep("bar", "stdout"))
 end
============================================================
--- test/func/branch_leaves_sync_bug/__driver__.lua	6b227867aeb3692dba4e68efdfe5c59ff5c15919
+++ test/func/branch_leaves_sync_bug/__driver__.lua	943c3f2d7c3294e5da221d44911c08511058acb2
@@ -46,7 +46,9 @@ chdir(test.root)
 
 -- Create Beth's workspace via checkout, so 'update' works
 chdir(test.root)
-check(abe_mtn("sync", "file://" .. test.root .. "/beth.db?*"), 0, false, false)
+
+test_uri="file://" .. url_encode_path(test.root .. "/beth.db") .. "?*"
+check(abe_mtn("sync", test_uri), 0, false, false)
 check(beth_mtn("checkout", "--branch", "testbranch", "Beth"), 0, false, false)
 chdir("Beth")
 check(beth_mtn("genkey", "address@hidden"), 0, false, false, string.rep("address@hidden", 2))
@@ -64,7 +66,7 @@ rev_b = base_revision()
 rev_b = base_revision()
 
 -- Sync dbs
-check(abe_mtn("sync", "file://" .. test.root .. "/beth.db?*"), 0, false, false)
+check(abe_mtn("sync", test_uri), 0, false, false)
 
 -- Abe merges
 chdir("Abe")
@@ -80,7 +82,8 @@ rev_d = base_revision()
 rev_d = base_revision()
 
 -- Sync dbs (not clear if direction of sync matters)
-check(beth_mtn("sync", "file://" .. test.root .. "/abe.db?*"), 0, false, false)
+test_uri="file://" .. url_encode_path(test.root .. "/abe.db") .. "?*"
+check(beth_mtn("sync", test_uri), 0, false, false)
 
 -- bug; rev_d and rev_c are both heads according to branch_leaves table.
 check(beth_mtn("db", "check"), 0, false, false)
============================================================
--- test/func/clone_aborts_on_branch_pattern_in_uri/__driver__.lua	bf16d8dcec86e4ae012d1c6078082f9d13a9fd80
+++ test/func/clone_aborts_on_branch_pattern_in_uri/__driver__.lua	e75946886b2b0b4ee301016860238e6315c22a59
@@ -6,9 +6,9 @@ copy("test.db", "test-clone.db")
 commit("mybranch")
 
 copy("test.db", "test-clone.db")
-testURI="file://" .. test.root .. "/test-clone.db?mybranch*"
 
-check(nodb_mtn("clone", testURI), 1, false, true)
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") .. "?mybranch*"
+check(nodb_mtn("clone", test_uri), 1, false, true)
 check(qgrep("you must specify an unambiguous branch to clone", "stderr"))
 
 -- the branch option is invalid in non-URI mode
@@ -16,7 +16,7 @@ check(qgrep("the '--branch' option is on
 check(qgrep("the '--branch' option is only valid with an URI to clone", "stderr"))
 
 -- finally, this should succeed
-check(nodb_mtn("clone", testURI, "--branch=mybranch"), 0, false, false)
+check(nodb_mtn("clone", test_uri, "--branch=mybranch"), 0, false, false)
 check(exists("mybranch"))
 check(readfile("foo") == readfile("mybranch/foo"))
 
============================================================
--- test/func/clone_weird_branch_names/__driver__.lua	205c20a2809513b93ee9ab6c1affb24070f284a2
+++ test/func/clone_weird_branch_names/__driver__.lua	0afc1816afa8d3e4b2dfb9fd016500f224432f0a
@@ -6,10 +6,11 @@ copy("test.db", "test-clone.db")
 commit("my-branch[1,2]-1^3")
 
 copy("test.db", "test-clone.db")
+
 -- some of the special chars need to get double-escaped to get "through"
-testURI="file://" .. test.root .. "/test-clone.db?my-branch\\\[1,2\\\]-1^3"
-
-check(nodb_mtn("clone", testURI), 0, false, false)
+test_uri="file://" .. url_encode_path(test.root .. "/test-clone.db") ..
+  "?" .. url_encode_query("my-branch\\\[1,2\\\]-1^3")
+check(nodb_mtn("clone", test_uri), 0, false, false)
 check(exists("my-branch[1,2]-1^3"))
 check(readfile("foo") == readfile("my-branch[1,2]-1^3/foo"))
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]