michael@0: #!/usr/bin/env python michael@0: michael@0: # Copyright (c) 2012 Google Inc. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: """ michael@0: Test that environment variables are ignored when --ignore-environment is michael@0: specified. michael@0: """ michael@0: michael@0: import os michael@0: michael@0: import TestGyp michael@0: michael@0: test = TestGyp.TestGyp(format='gypd') michael@0: michael@0: os.environ['GYP_DEFINES'] = 'FOO=BAR' michael@0: os.environ['GYP_GENERATORS'] = 'foo' michael@0: os.environ['GYP_GENERATOR_FLAGS'] = 'genflag=foo' michael@0: os.environ['GYP_GENERATOR_OUTPUT'] = 'somedir' michael@0: michael@0: expect = test.read('commands.gyp.ignore-env.stdout').replace('\r\n', '\n') michael@0: michael@0: test.run_gyp('commands.gyp', michael@0: '--debug', 'variables', michael@0: '--ignore-environment', michael@0: stdout=expect, ignore_line_numbers=True) michael@0: michael@0: # Verify the commands.gypd against the checked-in expected contents. michael@0: # michael@0: # Normally, we should canonicalize line endings in the expected michael@0: # contents file setting the Subversion svn:eol-style to native, michael@0: # but that would still fail if multiple systems are sharing a single michael@0: # workspace on a network-mounted file system. Consequently, we michael@0: # massage the Windows line endings ('\r\n') in the output to the michael@0: # checked-in UNIX endings ('\n'). michael@0: michael@0: contents = test.read('commands.gypd').replace('\r', '') michael@0: expect = test.read('commands.gypd.golden').replace('\r', '') michael@0: if not test.match(contents, expect): michael@0: print "Unexpected contents of `commands.gypd'" michael@0: test.diff(expect, contents, 'commands.gypd ') michael@0: test.fail_test() michael@0: michael@0: test.pass_test()