Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | |
michael@0 | 3 | # Copyright (c) 2012 Google Inc. All rights reserved. |
michael@0 | 4 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | # found in the LICENSE file. |
michael@0 | 6 | |
michael@0 | 7 | """ |
michael@0 | 8 | Test that environment variables are ignored when --ignore-environment is |
michael@0 | 9 | specified. |
michael@0 | 10 | """ |
michael@0 | 11 | |
michael@0 | 12 | import os |
michael@0 | 13 | |
michael@0 | 14 | import TestGyp |
michael@0 | 15 | |
michael@0 | 16 | test = TestGyp.TestGyp(format='gypd') |
michael@0 | 17 | |
michael@0 | 18 | os.environ['GYP_DEFINES'] = 'FOO=BAR' |
michael@0 | 19 | os.environ['GYP_GENERATORS'] = 'foo' |
michael@0 | 20 | os.environ['GYP_GENERATOR_FLAGS'] = 'genflag=foo' |
michael@0 | 21 | os.environ['GYP_GENERATOR_OUTPUT'] = 'somedir' |
michael@0 | 22 | |
michael@0 | 23 | expect = test.read('commands.gyp.ignore-env.stdout').replace('\r\n', '\n') |
michael@0 | 24 | |
michael@0 | 25 | test.run_gyp('commands.gyp', |
michael@0 | 26 | '--debug', 'variables', |
michael@0 | 27 | '--ignore-environment', |
michael@0 | 28 | stdout=expect, ignore_line_numbers=True) |
michael@0 | 29 | |
michael@0 | 30 | # Verify the commands.gypd against the checked-in expected contents. |
michael@0 | 31 | # |
michael@0 | 32 | # Normally, we should canonicalize line endings in the expected |
michael@0 | 33 | # contents file setting the Subversion svn:eol-style to native, |
michael@0 | 34 | # but that would still fail if multiple systems are sharing a single |
michael@0 | 35 | # workspace on a network-mounted file system. Consequently, we |
michael@0 | 36 | # massage the Windows line endings ('\r\n') in the output to the |
michael@0 | 37 | # checked-in UNIX endings ('\n'). |
michael@0 | 38 | |
michael@0 | 39 | contents = test.read('commands.gypd').replace('\r', '') |
michael@0 | 40 | expect = test.read('commands.gypd.golden').replace('\r', '') |
michael@0 | 41 | if not test.match(contents, expect): |
michael@0 | 42 | print "Unexpected contents of `commands.gypd'" |
michael@0 | 43 | test.diff(expect, contents, 'commands.gypd ') |
michael@0 | 44 | test.fail_test() |
michael@0 | 45 | |
michael@0 | 46 | test.pass_test() |