#------------------------------------------------------------------------------- # Copyright (c) 1997-2007, 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. #------------------------------------------------------------------------------- require "rbconfig" class TC_Enviro < Test::Unit::TestCase include P4RubyTest def name "Test client environment" end def test_enviro assert( p4, "Failed to create Perforce client" ) set_supported = !( ( Config::CONFIG[ 'target_os' ].downcase =~ /mswin|mingw|darwin/ ).nil? ) if( !p4.env( "P4DESCRIPTION" ) and set_supported ) # Set in registry assert( p4.set_env( "P4DESCRIPTION", "foo" ), "Cannot set P4DESCRIPTION in registry" ) assert_equal( p4.env( "P4DESCRIPTION" ), "foo" ) assert( p4.set_env( "P4DESCRIPTION", "" ), "Cannot clear P4DESCRIPTION from registry" ) end p4.user = "tony" p4.client = "myworkstation" p4.port = "myserver:1666" p4.password = "mypass" p4.prog = "somescript" p4.version = "2007.3/12345" ENV[ "P4IGNORE" ] = ".p4ignore" ENV[ "P4CLIENTPATH" ] = "/A/client/path/" assert_equal( p4.user, "tony" ) assert_equal( p4.client, "myworkstation" ) assert_equal( p4.port, "myserver:1666" ) assert_equal( p4.password, "mypass" ) assert_equal( p4.prog, "somescript" ) assert_equal( p4.version, "2007.3/12345" ) begin assert_equal( p4.env( "P4IGNORE" ), ".p4ignore" ) assert_equal( p4.env( "P4CLIENTPATH" ), "/A/client/path/" ) ensure ENV[ "P4CLIENTPATH" ] = nil end end end
Rework P4Ruby unit tests so they they are actually units. Now the
test order is irrelevant as all tests are standalone. Tidied up
the code formatting as well and removed all the tabs from the ruby
sources files. Added a modeline for vim users so consistent
indentation will be used.
Make P4Ruby build with Ruby 2.0.0 (on Mac at least). Mostly
cosmetic changes: just makes the build script handle the
Ruby 2 mkmf and the changes also work with 1.8.7 and 1.9.3
so they should probably have been like this all along.
Infrastructure change only - no functional change
|#8||14637||jmistry||Remove P4IGNORE and P4CLIENTPATH tests|
|#7||14620||jmistry||Add P4IGNORE and P4CLIENTPATH unit tests|
Fix P4#set_env unit test
Unit test incorrectly checked if the platform is Linux and skipped
part of the test if it was. So, this part of the test was still
running on platforms that do not support P4#set_env and would raise
an (expected) exception during the unit test.
Now it checks if the platform is Windows or Darwin, and if it is
it runs the registry setting test.
Support setting values in the registry through P4Ruby.
The command P4.set_env( var, val ) will set a registry variably on platforms
that support this action or through an exception on Unix.
The command P4.set_env( var ) resets a registry variable.
Updated unit test '02_environment.rb' to include registry set/check.
User visible change to be documented in release notes.
Fix unlink error on unit tests
Wrap the connect/disconnect in begin/ensure blocks to
ensure that the client disconnect even if there are failures
in a unit test.
Fix unicode unit test for 1.9. When the contents of a file
is stored in a String object, ruby 1.9 sets the String's
encoding to the current locale. This is overridden in the
test case and set to the correct value. This may need to
user visible change.
|#3||14522||tony||Add copyright notices to the test files.|
Add P4#version= and P4#version methods to get/set the version of
User-visible change to be documented in Scripting Interface Guide
Shuffle up the tests to make some room for one that tests setting
and getting of client environment vars.
Also give nice names to the tests while we're there.