#!/usr/bin/env python

"""
Test variable expansion of '<!()' syntax commands.
"""

import os

import TestGyp

test = TestGyp.TestGyp(format='gypd')

expect = test.read('commands.gyp.stdout')

# Set $HOME so that gyp doesn't read the user's actual
# ~/.gyp/include.gypi file, which may contain variables
# and other settings that would change the output.
os.environ['HOME'] = test.workpath()

test.run_gyp('commands.gyp',
             '--debug', 'variables', '--debug', 'general',
             stdout=expect)

test.must_match('commands.gypd', test.read('commands.gypd.golden'))

test.pass_test()

@@ -506,74 +506,694 @@
 t)%0A%0A
-test.must_match('commands.gypd', test.read('commands.gypd.golden')
+# Verify the commands.gypd against the checked-in expected contents.%0A#%0A# Normally, we should canonicalize line endings in the expected%0A# contents file setting the Subversion svn:eol-style to native,%0A# but that would still fail if multiple systems are sharing a single%0A# workspace on a network-mounted file system.  Consequently, we%0A# massage the Windows line endings ('%5Cr%5Cn') in the output to the%0A# checked-in UNIX endings ('%5Cn').%0A%0Acontents = test.read('commands.gypd').replace('%5Cr%5Cn', '%5Cn')%0Aexpect = test.read('commands.gypd.golden')%0Aif not test.match(contents, expect):%0A  print %22Unexpected contents of %60commands.gypd'%22%0A  self.diff(expect, contents, 'commands.gypd ')%0A  test.fail_test(
 )%0A%0At

Make the variables test cross-platform w.r.t. to line endings in the output. Review URL: http://codereview.chromium.org/174611