#!/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"
print `sed -e 's/Set\\([^O]\\)/XSet\\1/' dupjob-spec.txt | sed -e 's/List\\([^O]\\)/XList\\1/' | p4 jobspec -i` # 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
print `sh newjob.sh` # Create job000001
print `sh newjob.sh` # Create job000002
print `sh newjob.sh` # Create job000003
print `sed -e 's/Set/XSet/' dupjob-0.txt | sed -e 's/List/XList/' | p4 job -i` # Create job000004
print `sed -e 's/Set/XSet/' dupjob-0.txt | sed -e 's/List/XList/' | p4 job -i` # Create job000005
print `sed -e 's/Set/XSet/' dupjob-0.txt | sed -e 's/List/XList/' | p4 job -i` # Create job000006
print `sed -e 's/Set/XSet/' dupjob-0.txt | sed -e 's/List/XList/' | p4 job -i` # Create job000007
#
# 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}`
end
for x in 3..7 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; }' > dupjob2.#{x}.pre-post`
end
#
# Update JOB-5 Fields
#
`sed -e 's/Set/XSet/' dupjob-1.txt | sed -e 's/List/XList/' > job01.tmp` # Copy job for ReportedDate appending
update_job("job000005", "job01.tmp")
File.unlink("job01.tmp")
#
# SET JOB-5 as dup of JOB-4
#
`sed -e 's/Set/XSet/' dupjob-2.txt | sed -e 's/List/XList/' > job01.tmp` # Copy job for ReportedDate appending
update_job("job000005", "job01.tmp")
File.unlink("job01.tmp")
#
# SET JOB-7 as dup of JOB-6
#
`sed -e 's/Set/XSet/' dupjob-3.txt | sed -e 's/List/XList/' > job01.tmp` # Copy job for ReportedDate appending
update_job("job000007", "job01.tmp")
File.unlink("job01.tmp")
for x in 3..7 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; }' >> dupjob2.#{x}.pre-post`
end
for x in 3..7 do
cmd=`diff dupjob2.#{x}.pre-post dupjob2.#{x}.exp`.chomp
printf("Checking job%d:", x)
if cmd == nil || cmd.strip == "" then
printf(" passed\n")
File.unlink("dupjob2.#{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 |
|
|