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