#!/usr/local/bin/ruby
#
# Copyright 2005 Perforce Software. All rights reserved.
#
require "../../cur.triggers/P4Data.rb"
require "../../cur.triggers/P4Form.rb"
failures = 0
if isjobid("job000001") then
# TEST FOR CLEAN SYSTEM
printf("System currently populated restart server and try again\n")
else
printf("Populating system with test data\n")
print `sh newjob.sh` # Create job000001
print `sh newjob.sh` # Create job000002
print `sh newjob.sh` # Create job000003
print `sh newjob.sh` # Create job000004
print `sh newjob.sh` # Create job000005
print `sh newjob.sh` # Create job000006
cmd1="p4 job -o "
cmd2a="awk '{ print $0; } END { print \"RelatedJobs: "
cmd2b="\\n\"; }'"
cmd3="p4 job -f -i"
print `#{cmd1} job000001 | #{cmd2a} job000002 #{cmd2b}| #{cmd3}`
print `#{cmd1} job000003 | #{cmd2a} job000002 #{cmd2b}| #{cmd3}`
print `#{cmd1} job000004 | #{cmd2a} job000002 #{cmd2b}| #{cmd3}`
print `#{cmd1} job000005 | #{cmd2a} job000002 job000003 #{cmd2b} | #{cmd3}`
for x in 1..7 do
`p4 job -o job00000#{x} | egrep -v '^#' | grep -v 'Date' | sed -e 's=..../../.. ..:..:..=yyyy/mm/dd hh:mm:ss=' > related.#{x}.pre-post`
end
job = P4Form.new(`p4 job -o job000002`.split("\n"))
job.fields["RelatedJobs"] = "job000001, job000005, job000006"
p4proc = IO.popen("p4 job -f -i", "w+")
job.print(p4proc)
p4proc.close_write
saved = false
p4proc.each do |line|
if line =~ /Job job000002 saved/ then
saved = true
end
end
p4proc.close_read
if !saved then
printf("FAILED to write job000002\n")
end
print `sh newjob.sh "RelatedJobs: job000006"` # Create job000007
for x in 1..7 do
`p4 job -o job00000#{x} | egrep -v '^#' | grep -v 'Date' | sed -e 's=..../../.. ..:..:..=yyyy/mm/dd hh:mm:ss=' >> related.#{x}.pre-post`
cmd=`diff related.#{x}.pre-post related.#{x}.exp`.chomp
printf("Checking job%d:", x)
if cmd == nil || cmd.strip == "" then
printf(" passed\n")
File.unlink("related.#{x}.pre-post")
else
printf(" FAILED\n%s\n", cmd)
failures += 1
end
end
end
if failures > 0 then
printf("%d tests FAILED\n", failures)
else
printf("All tests passed\n")
end
# |
Change |
User |
Description |
Committed |
|
#1
|
8493 |
Alan H Teague |
Initial import of the Enhanced Jobs Project |
|
|