#!/usr/local/bin/ruby # # Copyright 2005 Perforce Software. All rights reserved. # require "../../cur.triggers/P4Data.rb" require "../../cur.triggers/P4Form.rb" failures = 0 if ischangelist("1") then # SKIP INIITIALIZATION printf "System currently populated with test data\n" else printf "Populating system with test data\n" `sh newjob.sh` # Create job000001 `sh newjob.sh` # Create job000002 `sh newjob.sh` # Create job000003 `sh changelist.sh one` # Create 1 `sh changelist.sh two` # Create 2 `sh changelist.sh three` # Create 3 `sh changelist.sh four` # Create 4 end for n in 1..3 do jobid = "job00000#{n}" `p4 job -o #{jobid} | sed -e 's/ / /g' | sed -e 's=..../../.. ..:..:..=yyyy/mm/dd hh:mm:ss=' | awk '/^[^#]/ { print $0; }' > changes.#{n}.pre-post` print `sh changefix.sh #{n} #{jobid}` if n == 3 then print `sh changefix.sh 4 #{jobid}` end `p4 job -o #{jobid} | sed -e 's/ / /g' | sed -e 's=..../../.. ..:..:..=yyyy/mm/dd hh:mm:ss=' | awk '/^[^#]/ { print $0; }' >> changes.#{n}.pre-post` cmd=`diff changes.#{n}.pre-post changes.#{n}.exp`.chomp printf("Checking %s:", jobid) if cmd == nil || cmd.strip == "" then printf(" passed\n") File.unlink("changes.#{n}.pre-post") else printf(" FAILED\n") print cmd failures += 1 end end for n in 1..3 do jobid = "job00000#{n}" nn = n + 4 `p4 fix -d -c #{nn} #{jobid}` if n == 3 then `p4 fix -d -c 8 #{jobid}` end `p4 job -o #{jobid} | sed -e 's/ / /g' | sed -e 's=..../../.. ..:..:..=yyyy/mm/dd hh:mm:ss=' | awk '/^[^#]/ { print $0; }' >> changes.#{n}.pre-post2` cmd=`diff changes.#{n}.pre-post2 changes.#{n}.exp2`.chomp printf("Checking %s:", jobid) if cmd == nil || cmd.strip == "" then printf(" passed\n") File.unlink("changes.#{n}.pre-post2") else printf(" FAILED\n") print 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