#------------------------------------------------------------------------------- # Copyright (c) 2010, Perforce Software, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE # SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. #------------------------------------------------------------------------------- class TC_Output < Test::Unit::TestCase include P4RubyTest def name "Test output" end def test_new_output # First test new output format assert( p4.connect, "Failed to connect to Perforce server" ) # Run a 'p4 sync' and ignore the output, then run it again # and we should get a 'file(s) up-to-date' message that we # want to trap. p4.at_exception_level( P4::RAISE_NONE ) do p4.run_sync end begin p4.run_sync assert( false, "Didn't get an exception!" ) rescue P4Exception w = p4.warnings[0] assert( !w.nil?, "Should have had a warning" ) assert( w.kind_of?( P4::Message ), "Didn't get a P4::Message object" ) assert( w.to_s =~ /up-to-date/, "Didn't get expected warning" ) assert( w.severity == P4::E_WARN, "Severity was not E_WARN" ) assert( w.generic == P4::EV_EMPTY, "Wasn't an empty message" ) end p4.disconnect # Now downgrade to 2010.1 and try again p4.api_level = 67 assert( p4.connect, "Failed to connect to Perforce server" ) begin p4.run_sync assert( false, "Didn't get an exception!" ) rescue P4Exception w = p4.warnings[0] assert( !w.nil?, "Should have had a warning" ) assert( w.kind_of?( String ), "Didn't get a String" ) assert( w =~ /up-to-date/, "Didn't get expected warning" ) end p4.disconnect end end