Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: test/win/gyptest-ninja-link-flags.py

Issue 11304012: Add support at test for /PROFILE in Ninja (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/win/gyptest-ninja-link-flags.py
===================================================================
--- test/win/gyptest-ninja-link-flags.py (revision 0)
+++ test/win/gyptest-ninja-link-flags.py (revision 0)
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2012 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Verifies that the 'Profile' attribute in VCLinker is extracted properly.
+"""
+
+import TestGyp
+
+import os
+import re
+import sys
+
+
+def GetLdFlags(target):
+ """GetLdFlags returns the value of ldflags from the specified .ninja file
+
+ Load the ninja file find the 'ldflags' key. Then concats lines when the
+ preceeding one ended with '$'."""
+
+ paths = ['linker-flags', 'out', 'Default','obj']
+ file_path = test.workpath(*paths + [target])
+
+ try:
+ lines = open(file_path, 'r').readlines()
+
+ except IOError, err:
+ print 'Failed to open %s with %s.' % (file_path, err)
+ return None
+
+ ldflags = None
+ appending = False
+ for line in lines:
+ if line[:9] == 'ldflags =':
+ appending = True
+ line = line[10:]
+ ldflags = ''
+ if appending:
+ line = line.strip()
+ if line[-1] == '$':
+ ldflags += line[:-1]
+ else:
+ ldflags += line
+ break
+ return ldflags
+
+
+def GetLdSwitch(target, arg):
+ """GetLdSwitch extract the uses of <arg> from ldflags."""
+
+ ldflags = GetLdFlags(target)
+ parser = re.compile('(%s((:\\S*)|(=\\S*))?)' % arg)
+ itr = parser.finditer(ldflags)
+ return [i.group(0) for i in itr]
+
+
+def VerifyLdSwitch(target, arg, val):
+ """VerifyLdSwitch of <arg> exactly matches <val>"""
+
+ found = GetLdSwitch(target, arg)
+ if val == found:
+ return True
+
+ print 'Target %s expected %s got %s' % (target, val, found)
+ return False
+
+
+if sys.platform == 'win32':
+ test = TestGyp.TestGyp(formats=['ninja'])
+ CHDIR = 'linker-flags'
+ test.run_gyp('profile.gyp', chdir=CHDIR)
+ test.build('profile.gyp', test.ALL, chdir=CHDIR)
+
+ # Verify it's turned on once when enabled in an EXE
+ if not VerifyLdSwitch('test_ninja_profile_true.ninja',
scottmg 2012/10/26 20:31:57 We've generally tried hard to not have tests like
noelallen1 2012/10/27 23:22:00 Switched to using dumpbin to verify. On 2012/10/2
+ '/PROFILE', ['/PROFILE']):
+ test.fail_test()
+
+ # Verify it's turned on once when enabled in an DLL
+ if not VerifyLdSwitch('test_ninja_profile_dll_true.ninja',
+ '/PROFILE', ['/PROFILE']):
+ test.fail_test()
+
+ # Verify it's not used by default in an EXE
+ if not VerifyLdSwitch('test_ninja_profile_no.ninja', '/PROFILE', []):
+ test.fail_test()
+
+ # Verify it's not used when disabled in a DLL
+ if not VerifyLdSwitch('test_ninja_profile_dll_false.ninja',
+ '/PROFILE', []):
+ test.fail_test()
+ test.pass_test()
Property changes on: test\win\gyptest-ninja-link-flags.py
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698