#!/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" `(cd ../..; sh p4user.setup karen)` # Add user `sh newjob.sh` # Create job000001 `sh newjob.sh` # Create job000002 `sh newjob.sh` # Create job000003 `sh newjob.sh` # Create job000004 `sh newjob.sh` # Create job000005 `sh newjob.sh` # Create job000006 `sh newjob.sh` # Create job000007 `sh newjob.sh` # Create job000008 end for x in 1..8 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; }' > owner2.#{x}.pre-post` # # Setup Jobs Appropriately # print `p4 job -o job00000#{x} >> job01.tmp` if x == 1 then # ClosedOwner == OwnedBy, OwnedBy unchanged print `echo "ClosedOwner: one" >> job01.tmp` print `echo "ClosedBy: one" >> job01.tmp` print `echo "EJPUserID: one" >> job01.tmp` elsif x == 2 then # ClosedOwner == P4Flow owner, OwnedBy unchanged print `echo "ClosedOwner: karen" >> job01.tmp` print `echo "ClosedBy: two" >> job01.tmp` print `echo "EJPUserID: one" >> job01.tmp` elsif x == 3 then # ClosedOwner == neither OwnedBy nor P4Flow owner, OwnedBy unchanged print `echo "ClosedOwner: two" >> job01.tmp` elsif x == 4 then # No ClosedOwner, OwnedBy unchanged elsif x == 5 then # ClosedOwner == OwnedBy, OwnedBy changed print `echo "ClosedOwner: one" >> job01.tmp` elsif x == 6 then # ClosedOwner == P4Flow owner, OwnedBy changed print `echo "ClosedOwner: karen" >> job01.tmp` elsif x == 7 then # ClosedOwner == neither OwnedBy nor P4Flow owner, OwnedBy changed print `echo "ClosedOwner: two" >> job01.tmp` elsif x == 8 then # No ClosedOwner, OwnedBy changed end print `p4 job -f -i < job01.tmp` File.unlink("job01.tmp") end for x in 1..8 do # # Mark Jobs as closed # print `p4 job -o job00000#{x} | egrep -v '^Status:' >> job01.tmp` print `echo "Status: closed" >> job01.tmp` if x == 1 then # ClosedOwner == OwnedBy, OwnedBy unchanged elsif x == 2 then # ClosedOwner == P4Flow owner, OwnedBy unchanged elsif x == 3 then # ClosedOwner == neither OwnedBy nor P4Flow owner, OwnedBy unchanged elsif x == 4 then # No ClosedOwner, OwnedBy unchanged elsif x == 5 then # ClosedOwner == OwnedBy, OwnedBy changed print `echo "OwnedBy: three" >> job01.tmp` elsif x == 6 then # ClosedOwner == P4Flow owner, OwnedBy changed print `echo "OwnedBy: three" >> job01.tmp` elsif x == 7 then # ClosedOwner == neither OwnedBy nor P4Flow owner, OwnedBy changed print `echo "OwnedBy: three" >> job01.tmp` elsif x == 8 then # No ClosedOwner, OwnedBy changed print `echo "OwnedBy: three" >> job01.tmp` end print `p4 job -f -i < job01.tmp` File.unlink("job01.tmp") end for x in 1..8 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; }' >> owner2.#{x}.pre-post` end for x in 1..8 do cmd=`diff owner2.#{x}.pre-post owner2.#{x}.exp`.chomp printf("Checking job%d:", x) if cmd == nil || cmd.strip == "" then printf(" passed\n") File.unlink("owner2.#{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