require 'test/unit' class MoveTest < Test::Unit::TestCase include MirrorTest def testSimpleMove root = use_source file1 = File.join(root, "file1") File.open(file1, "w") do |f| f.puts("Some content") end @p4.run_add(file1) @p4.run_submit("-d", "File added") file2 = File.join(root, "file2") @p4.run_edit(file1) @p4.run_move(file1, file2) mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 2, "Not two files open under target root") end def testMoveOldRevision root = use_source file1 = File.join(root, "file1") File.open(file1, "w") do |f| f.puts("Some content") end @p4.run_add(file1) @p4.run_submit("-d", "File added") # edit once @p4.run_edit(file1) File.open(file1, "a") do |f| f.puts("More content") end @p4.run_submit("-d", "File edited") # edit twice @p4.run_edit(file1) File.open(file1, "a") do |f| f.puts("More content") end @p4.run_submit("-d", "File edited") @p4.run_sync("#{file1}#1") @p4.run_edit(file1) # editing of old revision, will send out message that we need to resolve File.open(file1, "a") do |f| f.puts("Different content") end @p4.run_sync("#{file1}#2") @p4.run_resolve("-ay") file2 = File.join(root, "file2") @p4.run_move(file1, file2) @p4.run_sync(file2) # will bring up the request to resolve mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 2, "Not two files open under target root") end def testMoveWithIntegrate root = use_source file1 = File.join(root, "file1") file2 = File.join(root, "file2") file3 = File.join(root, "file3") File.open(file1, "w") do |f| f.puts("Some content") end @p4.run_add(file1) @p4.run_submit("-d", "File added") # integrate @p4.run_integrate(file1, file2) @p4.run_integrate(file1, file3) @p4.run_submit("-d", "Branched twice") # modify branched files @p4.run_edit("-t", "text+x", file2) @p4.run_edit("-t", "text+m", file3) File.open(file2, "a") do |f| f.puts("Two content") end File.open(file3, "a") do |f| f.puts("Three content") end @p4.run_submit("-d", "Updated branched files with different types") # Test # Integrate 2 into 1 # Downgrade to edit # Move 1 to 1_moved # Integrate 3 into 1_moved # Mirror # Does the order depend on the outcome? @p4.run_integrate(file2, file1) @p4.run_resolve do |md| if md.content_resolve? File.open(md.result_path, "w") do |f| f.puts("Totally different content") end "ae" else "at" end end # now edit and move file_moved = File.join(root, "file_moved") @p4.run_edit(file1) # downgrade integrate to an edit for the move @p4.run_move(file1, file_moved) # now we integrate in file3 @p4.run_integrate(file3, file_moved) mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 2, "Not two files open under target root") end end