From 47e8e72a80a89ce2f88a40c70eae1c1326c89e06 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Thu, 26 Jun 2014 16:32:26 +0000 Subject: [PATCH] Make the clang-tidy-diff.py test conditional on the presence of Python 2.7. Use the python binary from the configuration. llvm-svn: 211789 --- clang-tools-extra/test/Makefile | 1 + clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp | 3 ++- clang-tools-extra/test/lit.cfg | 7 +++++++ clang-tools-extra/test/lit.site.cfg.in | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/test/Makefile b/clang-tools-extra/test/Makefile index 6e39837..1dcf7cd 100644 --- a/clang-tools-extra/test/Makefile +++ b/clang-tools-extra/test/Makefile @@ -52,6 +52,7 @@ lit.site.cfg: FORCE @$(ECHOPATH) s=@CLANG_TOOLS_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> lit.tmp @$(ECHOPATH) s=@CLANG_TOOLS_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> lit.tmp @$(ECHOPATH) s=@CLANG_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp + @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@ @-rm -f lit.tmp diff --git a/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp b/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp index ab0b0f1..159431d 100644 --- a/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp +++ b/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp @@ -1,6 +1,7 @@ +// REQUIRES: python27 // RUN: sed 's/placeholder_for_f/f/' %s > %t.cpp // RUN: clang-tidy -checks=-*,misc-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s -// R_U_N: not diff -U0 %s %t.cpp | python %S/../../clang-tidy/tool/clang-tidy-diff.py -checks=-*,misc-use-override -- -std=c++11 2>&1 | FileCheck %s +// RUN: not diff -U0 %s %t.cpp | %python %S/../../clang-tidy/tool/clang-tidy-diff.py -checks=-*,misc-use-override -- -std=c++11 2>&1 | FileCheck %s struct A { virtual void f() {} virtual void g() {} diff --git a/clang-tools-extra/test/lit.cfg b/clang-tools-extra/test/lit.cfg index 41a17cb..c58f54e 100644 --- a/clang-tools-extra/test/lit.cfg +++ b/clang-tools-extra/test/lit.cfg @@ -174,3 +174,10 @@ if platform.system() not in ['Windows'] or lit_config.getBashPath() != '': # ANSI escape sequences in non-dumb terminal if platform.system() not in ['Windows']: config.available_features.add('ansi-escape-sequences') + +config.substitutions.append( ('%python', config.python_executable) ) + +import sys +# Scripts using argparse need Python 2.7. +if sys.version_info >= (2, 7): + config.available_features.add('python27') diff --git a/clang-tools-extra/test/lit.site.cfg.in b/clang-tools-extra/test/lit.site.cfg.in index 277f648..35f85168 100644 --- a/clang-tools-extra/test/lit.site.cfg.in +++ b/clang-tools-extra/test/lit.site.cfg.in @@ -7,6 +7,7 @@ config.llvm_libs_dir = "@LLVM_LIBS_DIR@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@" config.clang_tools_dir = "@CLANG_TOOLS_DIR@" +config.python_executable = "@PYTHON_EXECUTABLE@" config.target_triple = "@TARGET_TRIPLE@" # Support substitution of the tools and libs dirs with user parameters. This is -- 2.7.4