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.issue-176: f0e8fc25accd506b9


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.issue-176: f0e8fc25accd506b9c4bcfce29b384a4801ebdc8
Date: Tue, 14 Feb 2012 23:56:39 +0100 (CET)

revision:            f0e8fc25accd506b9c4bcfce29b384a4801ebdc8
date:                2012-02-14T22:52:09
author:              Richard Hopkins <address@hidden>
branch:              net.venge.monotone.issue-176
changelog:
Create tests for issue 176 - parentheses incorrectly reported as mismatched
in selectors

manifest:
format_version "1"

new_manifest [acdabd5c3451af06747d70da206a510c3235eedb]

old_revision [377d75d780a12a552941539f2e6a6e8d609fadb7]

add_dir "test/func/selectors_with_parentheses"

add_file "test/func/selectors_with_parentheses/__driver__.lua"
 content [bb61cc3e80cec408f632a91efce2862e4cd48482]
============================================================
--- /dev/null	
+++ test/func/selectors_with_parentheses/__driver__.lua	bb61cc3e80cec408f632a91efce2862e4cd48482
@@ -0,0 +1,85 @@
+-- See issue 176 - https://code.monotone.ca/p/monotone/issues/176/
+-- It reports parentheses being mismatched when they actually aren't.
+-- We're primarily testing the selector parsing here and making sure
+-- the command succeeds rather than checking the data.
+--
+-- The example given used the parentheses to combine multiple
+-- selectors with |, where A, B, and C represent other selectors.
+-- eg. mtn au select (A|B)/C
+-- However, the problem could still be reproduced with
+-- mtn au select (A)/C
+mtn_setup()
+
+-- Setup some helper functions for creating dummy data
+do
+   local num = 0
+   function ci(branch, parent, author)
+      num = num + 1
+      if parent ~= nil
+      then
+	 check(mtn("up", "-r", parent), 0, nil, false)
+      end
+      addfile("file-" .. num, "foo")
+      check(mtn("commit", "-b", branch, "--author", author, "-mx"), 0, nil, false)
+      return base_revision()
+   end
+   function merge(rev1, rev2, branch, author)
+      check(mtn("explicit_merge", rev1, rev2, branch, "--author", author), 0, nil, true)
+      local result = readfile("stderr"):match("%[merged%] (%x+)")
+      L("Merge result: " .. result .. "\n")
+      check(result:len() == 40)
+      return result
+   end
+   function expect(selector, ...)
+      check(mtn("automate", "select", selector), 0, true, nil)
+      local linecount = 0;
+      local expected = {...}
+      local ok = true
+      for line in io.lines("stdout")
+      do
+	 linecount = linecount + 1
+	 local idx = nil
+	 for k,v in ipairs(expected)
+	 do
+	    if v == line then idx = k end
+	 end
+	 if idx == nil
+	 then
+	    L("Did not expect " .. line .. "\n")
+	    ok = false
+	 else
+	    expected[idx] = true
+	 end
+      end
+      for k,v in ipairs(expected)
+      do
+	 if v ~= true
+	 then
+	    L("Expected " .. v .. "\n")
+	    ok = false
+	 end
+      end
+      check(ok)
+   end
+   function approve(branch, rev)
+      check(mtn("approve", "-b", branch, rev), 0, nil, false)
+   end
+end
+
+-- Create dummy data
+root = ci("testbranch", nil, "Joe")
+lhs = ci("testbranch", root, "Joe")
+rhs = ci("testbranch", root, "Anne")
+m = merge(lhs, rhs, "testbranch", "Anne")
+approve("otherbranch", lhs)
+other = ci("otherbranch", lhs, "Jim")
+other_2 = ci("otherbranch", other, "Jim")
+
+-- Test reported example where parentheses are used for grouping multiple selectors
+check(mtn("automate", "select", "(a:Joe|a:Anne)/b:testbranch"), 0, true, nil)
+-- Simplified case using single selector
+check(mtn("automate", "select", "(a:Joe)/b:testbranch"), 0, true, nil)
+
+-- Now lets swap the selectors around - should still work (and get same data if we cared)
+check(mtn("automate", "select", "b:testbranch/(a:Joe|a:Anne)"), 0, true, nil)
+check(mtn("automate", "select", "b:testbranch/(a:Joe)"), 0, true, nil)

reply via email to

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