Home | History | Annotate | Download | only in prune_targets
      1 #!/usr/bin/env python
      2 
      3 # Copyright (c) 2013 Google Inc. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 """
      8 Verifies --root-target removes the unnecessary targets.
      9 """
     10 
     11 import TestGyp
     12 
     13 test = TestGyp.TestGyp()
     14 # The xcode-ninja generator has its own logic for which targets to include
     15 if test.format == 'xcode-ninja':
     16   test.skip_test()
     17 
     18 build_error_code = {
     19   'cmake': 1,
     20   'make': 2,
     21   'msvs': 1,
     22   'ninja': 1,
     23   'xcode': 65,
     24 }[test.format]
     25 
     26 # By default, everything will be included.
     27 test.run_gyp('test1.gyp')
     28 test.build('test2.gyp', 'lib1')
     29 test.build('test2.gyp', 'lib2')
     30 test.build('test2.gyp', 'lib3')
     31 test.build('test2.gyp', 'lib_indirect')
     32 test.build('test1.gyp', 'program1')
     33 test.build('test1.gyp', 'program2')
     34 test.build('test1.gyp', 'program3')
     35 
     36 # With deep dependencies of program1 only.
     37 test.run_gyp('test1.gyp', '--root-target=program1')
     38 test.build('test2.gyp', 'lib1')
     39 test.build('test2.gyp', 'lib2', status=build_error_code, stderr=None)
     40 test.build('test2.gyp', 'lib3', status=build_error_code, stderr=None)
     41 test.build('test2.gyp', 'lib_indirect')
     42 test.build('test1.gyp', 'program1')
     43 test.build('test1.gyp', 'program2', status=build_error_code, stderr=None)
     44 test.build('test1.gyp', 'program3', status=build_error_code, stderr=None)
     45 
     46 # With deep dependencies of program2 only.
     47 test.run_gyp('test1.gyp', '--root-target=program2')
     48 test.build('test2.gyp', 'lib1', status=build_error_code, stderr=None)
     49 test.build('test2.gyp', 'lib2')
     50 test.build('test2.gyp', 'lib3', status=build_error_code, stderr=None)
     51 test.build('test2.gyp', 'lib_indirect')
     52 test.build('test1.gyp', 'program1', status=build_error_code, stderr=None)
     53 test.build('test1.gyp', 'program2')
     54 test.build('test1.gyp', 'program3', status=build_error_code, stderr=None)
     55 
     56 # With deep dependencies of program1 and program2.
     57 test.run_gyp('test1.gyp', '--root-target=program1', '--root-target=program2')
     58 test.build('test2.gyp', 'lib1')
     59 test.build('test2.gyp', 'lib2')
     60 test.build('test2.gyp', 'lib3', status=build_error_code, stderr=None)
     61 test.build('test2.gyp', 'lib_indirect')
     62 test.build('test1.gyp', 'program1')
     63 test.build('test1.gyp', 'program2')
     64 test.build('test1.gyp', 'program3', status=build_error_code, stderr=None)
     65 
     66 test.pass_test()
     67