#!/usr/local/bin/ruby
#
# Copyright 2005 Perforce Software. All rights reserved.
#
require "../../cur.triggers/P4Data.rb"
require "../../cur.triggers/P4Form.rb"
def update_job(jobid, changefile)
job = P4Form.new(`p4 job -o #{jobid}`.split("\n"))
job2 = P4Form.new(`cat #{changefile}`.split("\n"))
job2.fields.keys.each do |key|
job.fields[key] = job2.fields[key]
end
p4proc = IO.popen("p4 job -i", "w+")
job.print(p4proc)
p4proc.close_write
saved = false
p4proc.each do |line|
if line =~ /Job #{jobid} saved/ then
saved = true
end
end
p4proc.close_read
if !saved then
printf("FAILED to write #{jobid}\n")
end
end
failures = 0
if ischangelist("1") then
# SKIP INIITIALIZATION
printf "System currently populated with test data\n"
else
printf "Populating system with test data\n"
`p4 jobspec -i < dupjob-spec.txt` # Define the jobspec
`sh changelist.sh one` # Create changelist 1
`sh changelist.sh two` # Create changelist 2
`sh changelist.sh three` # Create changelist 3
`sh changelist.sh four` # Create changelist 4
`sh changelist.sh five` # Create changelist 5
`sh changelist.sh siz` # Create changelist 6
`sh newjob.sh` # Create job000001
`sh newjob.sh` # Create job000002
`sh newjob.sh` # Create job000003
`p4 job -i < dupjob-0.txt` # Create job000004
`p4 job -i < dupjob-0.txt` # Create job000005
`p4 job -i < dupjob-0.txt` # Create job000006
`p4 job -i < dupjob-0.txt` # Create job000007
`sh newjob.sh` # Create job000008
`sh newjob.sh` # Create job000009
#
# Mark JOB-7 and JOB-4 as related
# Mark JOB-7 and JOB-3 as related
#
cmd1="p4 job -o "
cmd2a="awk '{ print $0; } END { print \"RelatedJobs: "
cmd2b="\\n\"; }'"
cmd3="p4 job -i"
print `#{cmd1} job000007 | #{cmd2a} job000003 job000004 #{cmd2b}| #{cmd3}`
#
# Mark JOB-6 and JOB-3 as related
#
print `#{cmd1} job000006 | #{cmd2a} job000003 #{cmd2b}| #{cmd3}`
#
# SET JOB-9 as dup of JOB-8
#
print `p4 job -o job000009 | egrep -v '^Status:' > job01.tmp`
`echo \"DuplicateOf: job000008\" >> job01.tmp`
`echo \"Status: duplicate\" >> job01.tmp`
print `p4 job -i < job01.tmp`
File.unlink("job01.tmp")
end
for x in 3..9 do
`p4 job -o job00000#{x} | grep -v 'Date' | sed -e 's/ / /g' | sed -e 's=..../../.. ..:..:..=yyyy/mm/dd hh:mm:ss=' | awk '/^[^#]/ { print $0; }' > dupjob.#{x}.pre-post`
end
#
# Update JOB-5 Fields
#
update_job("job000005", "dupjob-1.txt")
#
# SET JOB-5 as dup of JOB-4
#
update_job("job000005", "dupjob-2.txt")
#
# SET JOB-7 as dup of JOB-6
#
update_job("job000007", "dupjob-3.txt")
#
# UNSET JOB-9 as dup of JOB-8
#
print `p4 job -o job000009 | egrep -v '^(Status|DuplicateOf):' > job01.tmp`
`echo \"Status: open\" >> job01.tmp`
print `p4 job -i < job01.tmp`
File.unlink("job01.tmp")
for x in 3..9 do
`p4 job -o job00000#{x} | grep -v 'Date' | sed -e 's/ / /g' | sed -e 's=..../../.. ..:..:..=yyyy/mm/dd hh:mm:ss=' | awk '/^[^#]/ { print $0; }' >> dupjob.#{x}.pre-post`
end
for x in 3..9 do
cmd=`diff dupjob.#{x}.pre-post dupjob.#{x}.exp`.chomp
printf("Checking job%d:", x)
if cmd == nil || cmd.strip == "" then
printf(" passed\n")
File.unlink("dupjob.#{x}.pre-post")
else
printf(" FAILED\n%s\n", cmd)
failures += 1
end
end
printf "\n"
if failures > 0 then
printf "ALL TESTS DID NOT PASS: %d failed\n", failures
exit 1
else
printf "All tests PASSED\n"
exit 0
end
# |
Change |
User |
Description |
Committed |
|
#1
|
8493 |
Alan H Teague |
Initial import of the Enhanced Jobs Project |
|
|