@ -55,7 +55,8 @@ class GclientTestCase(GClientBaseTestCase):
def __init__ ( self , test_case , verbose = False , spec = None ,
config_filename = ' a_file_name ' ,
entries_filename = ' a_entry_file_name ' ,
deps_file = ' a_deps_file_name ' , force = False , nohooks = False ) :
deps_file = ' a_deps_file_name ' , force = False , nohooks = False ,
jobs = 1 ) :
self . verbose = verbose
self . spec = spec
self . name = None
@ -64,6 +65,8 @@ class GclientTestCase(GClientBaseTestCase):
self . deps_file = deps_file
self . force = force
self . nohooks = nohooks
self . jobs = jobs
self . revision = None
self . revisions = [ ]
self . manually_grab_svn_rev = True
self . deps_os = None
@ -296,12 +299,27 @@ class TestDoRevert(GenericCommandTestCase):
self . BadClient ( gclient . DoRevert )
def CompareOptions ( options ) :
def _Compare ( other ) :
options_keys = [ i for i in dir ( options ) if not i . startswith ( ' _ ' ) ]
other_keys = [ i for i in dir ( other ) if not i . startswith ( ' _ ' ) ]
if set ( options_keys ) != set ( other_keys ) :
return False
try :
for key in options_keys :
if getattr ( options , key ) != getattr ( other , key ) :
return False
return True
except AttributeError :
return False
return _Compare
class GClientClassTestCase ( GclientTestCase ) :
def testDir ( self ) :
members = [
' ConfigContent ' , ' FileImpl ' , ' FromImpl ' , ' GetVar ' , ' LoadCurrentConfig ' ,
' RunOnDeps ' , ' SaveConfig ' , ' SetConfig ' , ' SetDefaultConfig ' ,
' supported_commands ' , ' PrintRevInfo ' ,
' supported_commands ' , ' PrintRevInfo ' , ' GetSCMCommandClosure ' ,
]
# If you add a member, be sure to add the relevant test!
@ -384,7 +402,8 @@ class GClientClassTestCase(GclientTestCase):
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , solution_name
) . AndReturn ( scm_wrapper_sol )
# Then an update will be performed.
scm_wrapper_sol . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_sol . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# Then an attempt will be made to read its DEPS file.
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , solution_name , options . deps_file )
@ -444,7 +463,8 @@ class GClientClassTestCase(GclientTestCase):
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , solution_name
) . AndReturn ( scm_wrapper_sol )
# Then an update will be performed.
scm_wrapper_sol . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_sol . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# Then an attempt will be made to read its DEPS file.
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , solution_name , options . deps_file )
@ -458,7 +478,8 @@ class GClientClassTestCase(GclientTestCase):
self . root_dir ,
gclient . os . path . join ( solution_name , " src " , " t " )
) . AndReturn ( scm_wrapper_t )
scm_wrapper_t . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_t . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# After everything is done, an attempt is made to write an entries
# file.
@ -521,7 +542,8 @@ class GClientClassTestCase(GclientTestCase):
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , solution_name
) . AndReturn ( scm_wrapper_sol )
# Then an update will be performed.
scm_wrapper_sol . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_sol . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# Then an attempt will be made to read its DEPS file.
gclient . gclient_utils . FileRead (
gclient . os . path . join ( checkout_path , options . deps_file )
@ -539,8 +561,10 @@ class GClientClassTestCase(GclientTestCase):
self . root_dir ,
" src/t " ) . AndReturn ( scm_wrapper_t )
scm_wrapper_n . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_t . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_n . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
scm_wrapper_t . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# NOTE: the dep src/b should not create an scm at all.
@ -615,7 +639,8 @@ class GClientClassTestCase(GclientTestCase):
gclient . os . path . join ( self . root_dir , name_a , options . deps_file )
) . AndReturn ( deps_a )
# Then an update will be performed.
scm_wrapper_a . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_a . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# An scm will be requested for the second solution.
gclient . gclient_scm . CreateSCM ( url_b , self . root_dir , name_b ) . AndReturn (
@ -625,13 +650,15 @@ class GClientClassTestCase(GclientTestCase):
gclient . os . path . join ( self . root_dir , name_b , options . deps_file )
) . AndReturn ( deps_b )
# Then an update will be performed.
scm_wrapper_b . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_b . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# Finally, an scm is requested for the shared dep.
gclient . gclient_scm . CreateSCM ( ' http://svn.t/trunk ' , self . root_dir , ' src/t '
) . AndReturn ( scm_wrapper_dep )
# And an update is run on it.
scm_wrapper_dep . RunCommand ( ' update ' , options , self . args , [ ] )
scm_wrapper_dep . RunCommand ( ' update ' , mox . Func ( CompareOptions ( options ) ) ,
self . args , [ ] )
# After everything is done, an attempt is made to write an entries file.
gclient . gclient_utils . FileWrite (
@ -666,7 +693,8 @@ class GClientClassTestCase(GclientTestCase):
) . AndReturn ( False )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , name , options . deps_file )
) . AndReturn ( " Boo = ' a ' " )
@ -886,7 +914,8 @@ deps = {
) . AndReturn ( False )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , None
) . AndReturn ( scm_wrapper_src )
@ -896,7 +925,8 @@ deps = {
gclient . gclient_scm . CreateSCM (
webkit_path , self . root_dir , ' foo/third_party/WebKit '
) . AndReturn ( gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
self . mox . ReplayAll ( )
client = self . _gclient_gclient ( self . root_dir , options )
@ -950,7 +980,8 @@ deps = {
) . AndReturn ( False )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir ,
None ) . AndReturn ( scm_wrapper_src )
@ -959,7 +990,8 @@ deps = {
gclient . gclient_scm . CreateSCM ( webkit_path , self . root_dir ,
' foo/third_party/WebKit ' ) . AndReturn ( gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
self . mox . ReplayAll ( )
client = self . _gclient_gclient ( self . root_dir , options )
@ -986,7 +1018,8 @@ deps = {
) . AndReturn ( deps_content )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
self . mox . ReplayAll ( )
client = self . _gclient_gclient ( self . root_dir , options )
@ -1049,7 +1082,8 @@ deps = {
) . AndReturn ( False )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , name , options . deps_file )
) . AndReturn ( deps_content )
@ -1057,7 +1091,8 @@ deps = {
# base gets updated.
gclient . gclient_scm . CreateSCM ( base_url , self . root_dir , ' base ' ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , ' base ' , options . deps_file )
) . AndReturn ( base_deps_content )
@ -1065,7 +1100,8 @@ deps = {
# main gets updated.
gclient . gclient_scm . CreateSCM ( main_url , self . root_dir , ' main ' ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
# Process is done and will write an .gclient_entries.
gclient . os . path . exists (
@ -1112,7 +1148,8 @@ deps = {
) . AndReturn ( False )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , name , options . deps_file )
) . AndReturn ( deps_content )
@ -1120,7 +1157,8 @@ deps = {
# base gets updated.
gclient . gclient_scm . CreateSCM ( base_url , self . root_dir , ' base ' ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , ' base ' , options . deps_file )
) . AndReturn ( base_deps_content )
@ -1128,7 +1166,8 @@ deps = {
# main gets updated.
gclient . gclient_scm . CreateSCM ( main_url , self . root_dir , ' main ' ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
# Process is done and will write an .gclient_entries.
gclient . os . path . exists (
@ -1175,7 +1214,8 @@ deps = {
) . AndReturn ( False )
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , name , options . deps_file )
) . AndReturn ( deps_content )
@ -1183,7 +1223,8 @@ deps = {
# base gets updated.
gclient . gclient_scm . CreateSCM ( base_url , self . root_dir , ' base ' ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , ' base ' , options . deps_file )
) . AndReturn ( base_deps_content )
@ -1195,7 +1236,8 @@ deps = {
) . AndReturn ( ' svn://base ' + main_url )
gclient . gclient_scm . CreateSCM ( ' svn://base ' + main_url , self . root_dir ,
' main ' ) . AndReturn ( gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
# Process is done and will write an .gclient_entries.
gclient . os . path . exists (
@ -1227,7 +1269,8 @@ deps = {
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
options = self . Options ( )
gclient . gclient_scm . CreateSCM . RunCommand ( ' update ' , options , self . args , [ ] )
gclient . gclient_scm . CreateSCM . RunCommand (
' update ' , mox . Func ( CompareOptions ( options ) ) , self . args , [ ] )
gclient . gclient_utils . FileRead (
gclient . os . path . join ( self . root_dir , name , options . deps_file )
) . AndReturn ( deps_content )
@ -1241,7 +1284,8 @@ deps = {
# This is where gclient tries to do the initial checkout.
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , target ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand ( ' updatesingle ' , options ,
gclient . gclient_scm . CreateSCM . RunCommand ( ' updatesingle ' ,
mox . Func ( CompareOptions ( options ) ) ,
self . args + [ " DEPS " ] , [ ] )
gclient . gclient_utils . FileWrite (
gclient . os . path . join ( self . root_dir , options . entries_filename ) ,
@ -1257,6 +1301,25 @@ deps = {
# implementation for Pulse plugin
pass
def testGetSCMCommandClosure ( self ) :
options = self . Options ( )
name = ' testGetSCMCommandClosure_name '
command = ' testGetSCMCommandClosure_command '
revision = ' 123 '
file_list = [ ]
called_options = self . Options ( )
called_options . revision = revision
gclient . gclient_scm . CreateSCM ( self . url , self . root_dir , name ) . AndReturn (
gclient . gclient_scm . CreateSCM )
gclient . gclient_scm . CreateSCM . RunCommand (
command , mox . Func ( CompareOptions ( called_options ) ) , self . args , file_list )
self . mox . ReplayAll ( )
client = self . _gclient_gclient ( self . root_dir , options )
closure = client . GetSCMCommandClosure ( name , self . url , revision , command ,
self . args , file_list )
closure ( )
# No test for internal functions.
def test_GetAllDeps ( self ) :
pass