[llvm-branch-commits] [llvm] [MC] Rewrite stdin.s to use python (PR #157232)
Aiden Grossman via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Sep 8 10:29:10 PDT 2025
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157232
>From d749f30964e57caa797b3df87ae88ffc3d4a2f54 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sun, 7 Sep 2025 17:39:19 +0000
Subject: [PATCH 1/2] feedback
Created using spr 1.3.6
---
llvm/test/MC/COFF/stdin.py | 17 +++++++++++++++++
llvm/test/MC/COFF/stdin.s | 1 -
2 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/MC/COFF/stdin.py
delete mode 100644 llvm/test/MC/COFF/stdin.s
diff --git a/llvm/test/MC/COFF/stdin.py b/llvm/test/MC/COFF/stdin.py
new file mode 100644
index 0000000000000..8b7b6ae1fba13
--- /dev/null
+++ b/llvm/test/MC/COFF/stdin.py
@@ -0,0 +1,17 @@
+# RUN: echo "// comment" > %t.input
+# RUN: which llvm-mc | %python %s %t
+
+import subprocess
+import sys
+
+llvm_mc_binary = sys.stdin.readlines()[0].strip()
+temp_file = sys.argv[1]
+input_file = temp_file + ".input"
+
+with open(temp_file, "w") as mc_stdout:
+ mc_stdout.seek(4)
+ subprocess.run(
+ [llvm_mc_binary, "-filetype=obj", "-triple", "i686-pc-win32", input_file],
+ stdout=mc_stdout,
+ check=True,
+ )
diff --git a/llvm/test/MC/COFF/stdin.s b/llvm/test/MC/COFF/stdin.s
deleted file mode 100644
index 8ceae7fdef501..0000000000000
--- a/llvm/test/MC/COFF/stdin.s
+++ /dev/null
@@ -1 +0,0 @@
-// RUN: bash -c '(echo "test"; llvm-mc -filetype=obj -triple i686-pc-win32 %s ) > %t'
>From 0bfe954d4cd5edf4312e924c278c59e57644d5f1 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 8 Sep 2025 17:28:59 +0000
Subject: [PATCH 2/2] feedback
Created using spr 1.3.6
---
llvm/test/MC/COFF/stdin.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/test/MC/COFF/stdin.py b/llvm/test/MC/COFF/stdin.py
index 8b7b6ae1fba13..1d9b50c022523 100644
--- a/llvm/test/MC/COFF/stdin.py
+++ b/llvm/test/MC/COFF/stdin.py
@@ -1,14 +1,22 @@
# RUN: echo "// comment" > %t.input
# RUN: which llvm-mc | %python %s %t
+import argparse
import subprocess
import sys
+parser = argparse.ArgumentParser()
+parser.add_argument("temp_file")
+arguments = parser.parse_args()
+
llvm_mc_binary = sys.stdin.readlines()[0].strip()
-temp_file = sys.argv[1]
+temp_file = arguments.temp_file
input_file = temp_file + ".input"
with open(temp_file, "w") as mc_stdout:
+ ## We need to test that starting on an input stream with a non-zero offset
+ ## does not trigger an assertion in WinCOFFObjectWriter.cpp, so we seek
+ ## past zero for STDOUT.
mc_stdout.seek(4)
subprocess.run(
[llvm_mc_binary, "-filetype=obj", "-triple", "i686-pc-win32", input_file],
More information about the llvm-branch-commits
mailing list