require 'test/unit' class EditTest < Test::Unit::TestCase include MirrorTest def testSimpleEdit 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", "New file") @p4.run_edit(file1) File.open(file1, "a") do |f| f.puts("More content") end mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 1, "Not one file open under target root") end def testEditOldRevision 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", "New file") @p4.run_edit(file1) File.open(file1, "a") do |f| f.puts("More content") end @p4.run_submit("-d", "New content") @p4.run_sync("#{file1}#1") @p4.run_edit("-ttext+m", file1) File.open(file1, "w") do |f| f.puts("New content") end @p4.run_sync(file1) # this will trigger two resolves mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 1, "Not one file open under target root") end def testDirtyIntegrate 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', "File1 added") file2 = File.join(root, "file2") file3 = File.join(root, "file3") @p4.run_integrate(file1, file2) @p4.run_integrate(file1, file3) @p4.run_submit('-d', "Branch File1 into File2 and File3") @p4.run_edit(file1) File.open(file1, "a") do |f| f.puts("More content") end @p4.run_edit("-t", "text+x", file3) File.open(file3, "a") do |f| f.puts("Different content") end @p4.run_submit('-d, "Updated file1 and file3"') @p4.run_integrate(file1, file2) @p4.run_integrate(file3, file2) @p4.run_edit(file2) # reopen for edit File.open(file2, "a") do |f| f.puts("Dirty edit") end mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 1, "Not one file open under target root") end def testDirtyIntegrateWithResolve 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', "File1 added") file2 = File.join(root, "file2") file3 = File.join(root, "file3") @p4.run_integrate(file1, file2) @p4.run_integrate(file1, file3) @p4.run_submit('-d', "Branch File1 into File2 and File3") @p4.run_edit(file1) File.open(file1, "a") do |f| f.puts("More content") end @p4.run_edit("-t", "text+x", file3) File.open(file3, "a") do |f| f.puts("Different content") end @p4.run_submit('-d, "Updated file1 and file3"') @p4.run_integrate(file1, file2) @p4.run_resolve("-at") # copy content @p4.run_integrate(file3, file2) @p4.run_resolve("-at") @p4.run_edit(file2) # reopen for edit File.open(file2, "a") do |f| f.puts("Dirty edit") end mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 1, "Not one file open under target root") end def testEditWithIntegrate 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', "File1 added") file2 = File.join(root, "file2") file3 = File.join(root, "file3") @p4.run_integrate(file1, file2) @p4.run_integrate(file1, file3) @p4.run_submit('-d', "Branch File1 into File2 and File3") @p4.run_edit(file1) File.open(file1, "a") do |f| f.puts("More content") end @p4.run_edit("-t", "text+x", file3) File.open(file3, "a") do |f| f.puts("Different content") end @p4.run_submit('-d, "Updated file1 and file3"') @p4.run_edit(file2) File.open(file2, "a") do |f| f.puts("Dirty edit") end @p4.run_integrate(file1, file2) @p4.run_resolve("-ay") @p4.run_integrate(file3, file2) mirror_and_compare() root = use_target opened = @p4.run_opened("#{root}/...") assert(opened.length == 1, "Not one file open under target root") end end