[Lldb-commits] [lldb] r218470 - gtest: remove recursive make, add python driver + Xcode error hook-up.

Todd Fiala todd.fiala at gmail.com
Thu Sep 25 15:12:33 PDT 2014


Author: tfiala
Date: Thu Sep 25 17:12:33 2014
New Revision: 218470

URL: http://llvm.org/viewvc/llvm-project?rev=218470&view=rev
Log:
gtest: remove recursive make, add python driver + Xcode error hook-up.

This change does the following:
* Removes the gtest/Makefile recursive-make-based calling strategy
  for gtest execution.
* Adds the gtest/do-gtest.py call script.
  - This handles finding and calling the Makefiles that really
    run tests.
  - This script also transforms the test output into something
    that Xcode can place a failure marker on when a test fails.
* Modifies the Xcode external build command target for gtest.
  It now calls the gtest/do-gtest.py script.

There is still room for improvement on Xcode integration of
do-gtest.py.  Essentially the next several lines of error reporting
from the gtest output should be coalesced into a single line so that
Xcode can tell more about the error directly in the editor.  Right now
it just puts a red mark and says "failure" but doesn't give any
details.

Added:
    lldb/trunk/gtest/do-gtest.py   (with props)
Removed:
    lldb/trunk/gtest/Makefile
    lldb/trunk/gtest/unittest/Makefile
Modified:
    lldb/trunk/gtest/gtest.xcodeproj/project.pbxproj

Removed: lldb/trunk/gtest/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/Makefile?rev=218469&view=auto
==============================================================================
--- lldb/trunk/gtest/Makefile (original)
+++ lldb/trunk/gtest/Makefile (removed)
@@ -1,5 +0,0 @@
-LEVEL := ./make
-
-SUBDIRS := unittest
-
-include $(LEVEL)/Makefile.rules

Added: lldb/trunk/gtest/do-gtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/do-gtest.py?rev=218470&view=auto
==============================================================================
--- lldb/trunk/gtest/do-gtest.py (added)
+++ lldb/trunk/gtest/do-gtest.py Thu Sep 25 17:12:33 2014
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import os
+import re
+import select
+import subprocess
+import sys
+
+def find_makefile_dirs():
+    makefile_dirs = []
+    for root, dirs, files in os.walk("."):
+        for file in files:
+            if file == "Makefile":
+                makefile_dirs.append(root)
+    return makefile_dirs
+
+_TESTDIR_RELATIVE_REGEX = re.compile(r"^([^/:]+:\d+:)")
+
+def filter_run_line(sub_expr, line):
+    return _TESTDIR_RELATIVE_REGEX.sub(sub_expr, line)
+ 
+def call_make(makefile_dir, extra_args=None):
+    command = ["make", "-C", makefile_dir]
+    if extra_args:
+        command.extend(extra_args)
+
+    # Replace the matched no-directory filename with one where the makefile directory is prepended.
+    sub_expr = makefile_dir + r"/\1";
+
+    proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+    while True:
+        reads = [proc.stdout.fileno(), proc.stderr.fileno()]
+        select_result = select.select(reads, [], [])
+
+        for fd in select_result[0]:
+            if fd == proc.stdout.fileno():
+                line = proc.stdout.readline()
+                print(filter_run_line(sub_expr, line.rstrip()))
+            elif fd == proc.stderr.fileno():
+                line = proc.stderr.readline()
+                print(filter_run_line(sub_expr, line.rstrip()), file=sys.stderr)
+
+        proc_retval = proc.poll()
+        if proc_retval != None:
+            # Process stopped.  Drain output before finishing up.
+
+            # Drain stdout.
+            while True:
+                line = proc.stdout.readline()
+                if line:
+                    print(filter_run_line(sub_expr, line.rstrip()))
+                else:
+                    break
+
+            # Drain stderr.
+            while True:
+                line = proc.stderr.readline()
+                if line:
+                    print(filter_run_line(sub_expr, line.rstrip()), file=sys.stderr)
+                else:
+                    break
+
+            return proc_retval
+
+
+global_retval = 0
+extra_args = None
+
+if len(sys.argv) > 1:
+    if sys.argv[1] == 'clean':
+        extra_args = ['clean']
+
+for makefile_dir in find_makefile_dirs():
+    print("found makefile dir: {}".format(makefile_dir))
+    retval = call_make(makefile_dir, extra_args)
+    if retval != 0:
+        global_retval = retval
+        
+sys.exit(global_retval)

Propchange: lldb/trunk/gtest/do-gtest.py
------------------------------------------------------------------------------
    svn:executable = *

Modified: lldb/trunk/gtest/gtest.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/gtest.xcodeproj/project.pbxproj?rev=218470&r1=218469&r2=218470&view=diff
==============================================================================
--- lldb/trunk/gtest/gtest.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/gtest/gtest.xcodeproj/project.pbxproj Thu Sep 25 17:12:33 2014
@@ -67,11 +67,11 @@
 /* Begin PBXLegacyTarget section */
 		23CDD8F319D4790700461DDC /* gtest */ = {
 			isa = PBXLegacyTarget;
-			buildArgumentsString = "$(ACTION)";
+			buildArgumentsString = "do-gtest.py $(ACTION)";
 			buildConfigurationList = 23CDD8F619D4790700461DDC /* Build configuration list for PBXLegacyTarget "gtest" */;
 			buildPhases = (
 			);
-			buildToolPath = /usr/bin/make;
+			buildToolPath = /usr/bin/python;
 			buildWorkingDirectory = .;
 			dependencies = (
 			);

Removed: lldb/trunk/gtest/unittest/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/unittest/Makefile?rev=218469&view=auto
==============================================================================
--- lldb/trunk/gtest/unittest/Makefile (original)
+++ lldb/trunk/gtest/unittest/Makefile (removed)
@@ -1,7 +0,0 @@
-LEVEL := ../make
-
-SUBDIRS := Plugins/Process/Linux
-
-$(info in unittest Makefile)
-
-include $(LEVEL)/Makefile.rules





More information about the lldb-commits mailing list