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

Side by Side Diff: test/lib/TestGyp.py

Issue 12314014: CMake generator. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Cleaner status munging. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 TestGyp.py: a testing framework for GYP integration tests. 6 TestGyp.py: a testing framework for GYP integration tests.
7 """ 7 """
8 8
9 import collections
10 import itertools
9 import os 11 import os
10 import re 12 import re
11 import shutil 13 import shutil
12 import stat 14 import stat
13 import subprocess 15 import subprocess
14 import sys 16 import sys
15 import tempfile 17 import tempfile
16 18
17 import TestCmd 19 import TestCmd
18 import TestCommon 20 import TestCommon
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 Verifies that a build of the specified target is up to date. 527 Verifies that a build of the specified target is up to date.
526 """ 528 """
527 kw['stdout'] = ("make: Nothing to be done for `%s'." % 529 kw['stdout'] = ("make: Nothing to be done for `%s'." %
528 self.target_name(target)) 530 self.target_name(target))
529 531
530 # We need to supply a custom matcher, since we don't want to depend on the 532 # We need to supply a custom matcher, since we don't want to depend on the
531 # exact stdout string. 533 # exact stdout string.
532 kw['match'] = self.match_single_line 534 kw['match'] = self.match_single_line
533 return self.build(gyp_file, target, **kw) 535 return self.build(gyp_file, target, **kw)
534 536
537
538 class TestGypCMake(TestGypBase):
539 """
540 Subclass for testing the GYP CMake generator.
Nico 2013/11/19 16:35:28 ", using cmake's ninja backend"?
bungeman-chromium 2013/11/20 20:54:51 Done. Way back when I had this set up so it could
541 """
542 format = 'cmake'
543 build_tool_list = ['cmake']
544 ALL = 'all'
545
546 def cmake_build(self, gyp_file, target=None, **kw):
547 arguments = kw.get('arguments', [])[:]
548
549 self.build_tool_list = ['cmake']
550 self.initialize_build_tool()
551
552 chdir = os.path.join(kw.get('chdir', '.'),
553 'out',
554 self.configuration_dirname())
555 kw['chdir'] = chdir
556
557 arguments.append('-G')
558 arguments.append('Ninja')
559
560 kw['arguments'] = arguments
561
562 stderr = kw.get('stderr', None)
563 if stderr:
564 kw['stderr'] = stderr.split('$$$')[0]
565
566 self.run(program=self.build_tool, **kw)
567
568 def ninja_build(self, gyp_file, target=None, **kw):
569 arguments = kw.get('arguments', [])[:]
570
571 self.build_tool_list = ['ninja']
572 self.initialize_build_tool()
573
574 # Add a -C output/path to the command line.
575 arguments.append('-C')
576 arguments.append(os.path.join('out', self.configuration_dirname()))
577
578 if target not in (None, self.DEFAULT):
579 arguments.append(target)
580
581 kw['arguments'] = arguments
582
583 stderr = kw.get('stderr', None)
584 if stderr:
585 stderrs = stderr.split('$$$')
586 kw['stderr'] = stderrs[1] if len(stderrs) > 1 else ''
587
588 return self.run(program=self.build_tool, **kw)
589
590 def build(self, gyp_file, target=None, status=0, **kw):
591 # Two tools must be run to build, cmake and the ninja.
592 # Allow cmake to succeed when the overall expectation is to fail.
593 if status is None:
594 kw['status'] = None
595 else:
596 if not isinstance(status, collections.Iterable): status = (status,)
597 kw['status'] = list(itertools.chain((0,), status))
598 self.cmake_build(gyp_file, target, **kw)
599 kw['status'] = status
600 self.ninja_build(gyp_file, target, **kw)
601
602 def run_built_executable(self, name, *args, **kw):
603 # Enclosing the name in a list avoids prepending the original dir.
604 program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
605 if sys.platform == 'darwin':
606 configuration = self.configuration_dirname()
607 os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration)
608 return self.run(program=program, *args, **kw)
609
610 def built_file_path(self, name, type=None, **kw):
611 result = []
612 chdir = kw.get('chdir')
613 if chdir:
614 result.append(chdir)
615 result.append('out')
616 result.append(self.configuration_dirname())
617 if type == self.STATIC_LIB:
618 if sys.platform != 'darwin':
619 result.append('obj.target')
620 elif type == self.SHARED_LIB:
621 if sys.platform != 'darwin' and sys.platform != 'win32':
622 result.append('lib.target')
623 subdir = kw.get('subdir')
624 if subdir and type != self.SHARED_LIB:
625 result.append(subdir)
626 result.append(self.built_file_basename(name, type, **kw))
627 return self.workpath(*result)
628
629 def up_to_date(self, gyp_file, target=None, **kw):
630 result = self.ninja_build(gyp_file, target, **kw)
631 if not result:
632 stdout = self.stdout()
633 if 'ninja: no work to do' not in stdout:
634 self.report_not_up_to_date()
635 self.fail_test()
636 return result
637
638
535 class TestGypMake(TestGypBase): 639 class TestGypMake(TestGypBase):
536 """ 640 """
537 Subclass for testing the GYP Make generator. 641 Subclass for testing the GYP Make generator.
538 """ 642 """
539 format = 'make' 643 format = 'make'
540 build_tool_list = ['make'] 644 build_tool_list = ['make']
541 ALL = 'all' 645 ALL = 'all'
542 def build(self, gyp_file, target=None, **kw): 646 def build(self, gyp_file, target=None, **kw):
543 """ 647 """
544 Runs a Make build using the Makefiles generated from the specified 648 Runs a Make build using the Makefiles generated from the specified
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 result.append(chdir) 1090 result.append(chdir)
987 configuration = self.configuration_dirname() 1091 configuration = self.configuration_dirname()
988 result.extend(['build', configuration]) 1092 result.extend(['build', configuration])
989 result.append(self.built_file_basename(name, type, **kw)) 1093 result.append(self.built_file_basename(name, type, **kw))
990 return self.workpath(*result) 1094 return self.workpath(*result)
991 1095
992 1096
993 format_class_list = [ 1097 format_class_list = [
994 TestGypGypd, 1098 TestGypGypd,
995 TestGypAndroid, 1099 TestGypAndroid,
1100 TestGypCMake,
996 TestGypMake, 1101 TestGypMake,
997 TestGypMSVS, 1102 TestGypMSVS,
998 TestGypNinja, 1103 TestGypNinja,
999 TestGypXcode, 1104 TestGypXcode,
1000 ] 1105 ]
1001 1106
1002 def TestGyp(*args, **kw): 1107 def TestGyp(*args, **kw):
1003 """ 1108 """
1004 Returns an appropriate TestGyp* instance for a specified GYP format. 1109 Returns an appropriate TestGyp* instance for a specified GYP format.
1005 """ 1110 """
1006 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) 1111 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT'))
1007 for format_class in format_class_list: 1112 for format_class in format_class_list:
1008 if format == format_class.format: 1113 if format == format_class.format:
1009 return format_class(*args, **kw) 1114 return format_class(*args, **kw)
1010 raise Exception, "unknown format %r" % format 1115 raise Exception, "unknown format %r" % format
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698