Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright (c) 2012 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 | Test that two targets with the same name generates an error. |
| 9 | """ |
| 10 | |
| 11 | import os |
| 12 | import sys |
| 13 | |
| 14 | import TestGyp |
| 15 | import TestCmd |
| 16 | |
| 17 | # TODO(sbc): Remove the use of match_re below, done because scons |
| 18 | # error messages were not consistent with other generators. |
| 19 | # Also remove input.py:generator_wants_absolute_build_file_paths. |
| 20 | |
| 21 | test = TestGyp.TestGyp() |
| 22 | |
| 23 | stderr = ('gyp: Duplicate target definitions for ' |
| 24 | '.*duplicate_targets.gyp:foo#target\n') |
| 25 | test.run_gyp('duplicate_targets.gyp', status=1, stderr=stderr, |
| 26 | match=TestCmd.match_re) |
| 27 | |
| 28 | stderr = ('.*: Unable to find targets in build file .*missing_targets.gyp.*') |
| 29 | test.run_gyp('missing_targets.gyp', status=1, stderr=stderr, |
| 30 | match=TestCmd.match_re_dotall) |
| 31 | |
| 32 | stderr = ('gyp: rule bar exists in duplicate, target ' |
| 33 | '.*duplicate_rule.gyp:foo#target\n') |
| 34 | test.run_gyp('duplicate_rule.gyp', status=1, stderr=stderr, |
| 35 | match=TestCmd.match_re) |
| 36 | |
| 37 | stderr = ("gyp: Key 'targets' repeated at level 1 with key path '' while " |
| 38 | "reading .*duplicate_node.gyp.*") |
| 39 | test.run_gyp('duplicate_node.gyp', '--check', status=1, stderr=stderr, |
| 40 | match=TestCmd.match_re_dotall) |
| 41 | |
| 42 | stderr = (".*target0.*target1.*target2.*target0.*") |
| 43 | test.run_gyp('dependency_cycle.gyp', status=1, stderr=stderr, |
| 44 | match=TestCmd.match_re_dotall) |
| 45 | |
| 46 | stderr = (".*file_cycle0.*file_cycle1.*file_cycle0.*") |
| 47 | test.run_gyp('file_cycle0.gyp', status=1, stderr=stderr, |
| 48 | match=TestCmd.match_re_dotall) |
| 49 | |
| 50 | stderr = 'gyp: Duplicate basenames in sources section, see list above\n' |
| 51 | test.run_gyp('duplicate_basenames.gyp', status=1, stderr=stderr) |
| 52 | |
| 53 | # Check if '--no-duplicate-basename-check' works. |
| 54 | if ((test.format == 'make' and sys.platform == 'darwin') or |
| 55 | (test.format == 'msvs' and |
| 56 | int(os.environ.get('GYP_MSVS_VERSION', 2010)) < 2010)): |
| 57 | stderr = 'gyp: Duplicate basenames in sources section, see list above\n' |
| 58 | test.run_gyp('duplicate_basenames.gyp', '--no-duplicate-basename-check', |
| 59 | status=1, stderr=stderr) |
| 60 | else: |
| 61 | test.run_gyp('duplicate_basenames.gyp', '--no-duplicate-basename-check') |
| 62 | |
| 63 | stderr = ("gyp: Dependency '.*missing_dep.gyp:missing.gyp#target' not found " |
| 64 | "while trying to load target .*missing_dep.gyp:foo#target\n") |
| 65 | test.run_gyp('missing_dep.gyp', status=1, stderr=stderr, |
| 66 | match=TestCmd.match_re) |
| 67 | |
| 68 | # Make sure invalid <!() command invocations say what command it was and |
| 69 | # mention the gyp file name. Use a "random" command name to trigger an ENOENT. |
| 70 | stderr = (".*invalid-command-name-egtyevNif3.*netDurj9.*missing_command.gyp.*") |
| 71 | test.run_gyp('missing_command.gyp', status=1, stderr=stderr, |
| 72 | match=TestCmd.match_re_dotall) |
| 73 | |
| 74 | # Make sure <!() commands that error out result in a message that mentions |
| 75 | # the command and gyp file name |
| 76 | stderr = (".*python.*-c.*import sys.*sys.exit.*3.*error_command.gyp.*") |
| 77 | test.run_gyp('error_command.gyp', status=1, stderr=stderr, |
| 78 | match=TestCmd.match_re_dotall) |
| 79 | |
| 80 | test.pass_test() |