Home | History | Annotate | Download | only in external_builder
      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 that msvs_external_builder being set will invoke the provided
      9 msvs_external_builder_build_cmd and msvs_external_builder_clean_cmd, and will
     10 not invoke MSBuild actions and rules.
     11 """
     12 
     13 import os
     14 import sys
     15 import TestGyp
     16 
     17 if int(os.environ.get('GYP_MSVS_VERSION', 0)) < 2010:
     18   sys.exit(0)
     19 
     20 test = TestGyp.TestGyp(formats=['msvs'], workdir='workarea_all')
     21 
     22 # without the flag set
     23 test.run_gyp('external.gyp')
     24 test.build('external.gyp', target='external')
     25 test.must_not_exist('external_builder.out')
     26 test.must_exist('msbuild_rule.out')
     27 test.must_exist('msbuild_action.out')
     28 test.must_match('msbuild_rule.out', 'msbuild_rule.py hello.z a b c')
     29 test.must_match('msbuild_action.out', 'msbuild_action.py x y z')
     30 os.remove('msbuild_rule.out')
     31 os.remove('msbuild_action.out')
     32 
     33 # with the flag set, using Build
     34 try:
     35   os.environ['GYP_DEFINES'] = 'use_external_builder=1'
     36   test.run_gyp('external.gyp')
     37   test.build('external.gyp', target='external')
     38 finally:
     39   del os.environ['GYP_DEFINES']
     40 test.must_not_exist('msbuild_rule.out')
     41 test.must_not_exist('msbuild_action.out')
     42 test.must_exist('external_builder.out')
     43 test.must_match('external_builder.out', 'external_builder.py build 1 2 3')
     44 os.remove('external_builder.out')
     45 
     46 # with the flag set, using Clean
     47 try:
     48   os.environ['GYP_DEFINES'] = 'use_external_builder=1'
     49   test.run_gyp('external.gyp')
     50   test.build('external.gyp', target='external', clean=True)
     51 finally:
     52   del os.environ['GYP_DEFINES']
     53 test.must_not_exist('msbuild_rule.out')
     54 test.must_not_exist('msbuild_action.out')
     55 test.must_exist('external_builder.out')
     56 test.must_match('external_builder.out', 'external_builder.py clean 4 5')
     57 os.remove('external_builder.out')
     58 
     59 test.pass_test()
     60