[PATCH] D135067: [lit] RUN commands without stdin.

2022-10-10 Thread James Henderson via Phabricator via cfe-commits
jhenderson added inline comments.



Comment at: llvm/utils/lit/tests/Inputs/shtest-stdin/print-stdin.py:6
+print(sys.stdin.read())
\ No newline at end of file


Nit: add newline at EOF.



Comment at: llvm/utils/lit/tests/shtest-stdin.py:28
+# CHECK-PIPE: foobar
+

Nit: Don't have multiple \n at EOF (there should be exactly one).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135067/new/

https://reviews.llvm.org/D135067

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135067: [lit] RUN commands without stdin.

2022-10-04 Thread Christian Sigg via Phabricator via cfe-commits
csigg updated this revision to Diff 465096.
csigg added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Fix clang tests that relied on empty input or accidentally did not provide the 
input in the RUN directive.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135067/new/

https://reviews.llvm.org/D135067

Files:
  clang/test/Analysis/analyzer-checker-config.c
  clang/test/Analysis/analyzer-config.c
  clang/test/Driver/cc1-response-files.c
  clang/test/Interpreter/incremental-mode.cpp
  clang/test/Modules/load-module-with-errors.m
  clang/test/OpenMP/target_uses_allocators.c
  clang/test/Preprocessor/elfiamcu-predefines.c
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/util.py
  llvm/utils/lit/tests/Inputs/shtest-stdin/lit.cfg
  llvm/utils/lit/tests/Inputs/shtest-stdin/print-stdin.py
  llvm/utils/lit/tests/shtest-stdin.py
  utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel
@@ -33,5 +33,15 @@
 "//llvm:not",
 ] + glob(["Inputs/**"]),
 )
-for src in glob(["*/*.py"])
+for src in glob(
+include = ["**/*.py"],
+exclude = [
+"Inputs/**",
+# FIXME: these tests fail under bazel.
+"discovery.py",
+"max-time.py",
+"selecting.py",
+"shtest-recursive-substitution.py",
+]
+)
 ]
Index: llvm/utils/lit/tests/shtest-stdin.py
===
--- /dev/null
+++ llvm/utils/lit/tests/shtest-stdin.py
@@ -0,0 +1,28 @@
+# REQUIRES: lit-max-individual-test-time
+
+###
+# Check tests do not receive spurious stdin input.
+###
+# RUN: not %{lit} %{inputs}/shtest-stdin/print-stdin.py \
+# RUN:   --param external=0 --timeout 1 \
+# RUN: | FileCheck --check-prefix=CHECK-STDIN %s
+#
+# RUN: not %{lit} %{inputs}/shtest-stdin/print-stdin.py \
+# RUN:   --param external=1 --timeout 1 \
+# RUN: | FileCheck --check-prefix=CHECK-STDIN %s
+#
+# CHECK-STDIN: TIMEOUT: shtest-stdin :: print-stdin.py
+
+###
+# Check tests do receive piped stdin input.
+###
+# RUN: echo foobar | %{lit} %{inputs}/shtest-stdin/print-stdin.py \
+# RUN:   --param external=0 -a \
+# RUN: | FileCheck --check-prefix=CHECK-PIPE %s
+#
+# RUN: echo foobar | %{lit} %{inputs}/shtest-stdin/print-stdin.py \
+# RUN:   --param external=1 -a \
+# RUN: | FileCheck --check-prefix=CHECK-PIPE %s
+#
+# CHECK-PIPE: foobar
+
Index: llvm/utils/lit/tests/Inputs/shtest-stdin/print-stdin.py
===
--- /dev/null
+++ llvm/utils/lit/tests/Inputs/shtest-stdin/print-stdin.py
@@ -0,0 +1,5 @@
+# Checks that lit provides no input to stdin.
+# RUN: %{python} %s
+import sys
+
+print(sys.stdin.read())
\ No newline at end of file
Index: llvm/utils/lit/tests/Inputs/shtest-stdin/lit.cfg
===
--- /dev/null
+++ llvm/utils/lit/tests/Inputs/shtest-stdin/lit.cfg
@@ -0,0 +1,26 @@
+# -*- Python -*-
+import os
+import sys
+
+import lit.formats
+
+config.name = 'shtest-stdin'
+
+externalShell = lit_config.params.get('external', '1') != '0'
+config.test_format = lit.formats.ShTest(execute_external=externalShell)
+config.suffixes = ['.py']
+
+config.test_source_root = os.path.dirname(__file__)
+config.test_exec_root = config.test_source_root
+config.target_triple = '(unused)'
+src_root = os.path.join(config.test_source_root, '..')
+
+pythonpath_list = [src_root]
+# Ensure the user's PYTHONPATH is included.
+if 'PYTHONPATH' in os.environ:
+pythonpath_list.append(os.environ['PYTHONPATH'])
+if 'PYTHONPATH' in config.environment:
+pythonpath_list.append(config.environment['PYTHONPATH'])
+config.environment['PYTHONPATH'] = os.pathsep.join(pythonpath_list)
+
+config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
Index: llvm/utils/lit/lit/util.py
===
--- llvm/utils/lit/lit/util.py
+++ llvm/utils/lit/lit/util.py
@@ -321,7 +321,7 @@
 * working directory ``cwd`` (str), use None to use the current
   working directory
 * environment ``env`` (dict), use None for none
-* Input to the command ``input`` (str), use string to pass
+* Input to the command ``input`` (str), use None to pass
   no input.