Skip to content

[AIX] Re-apply: Remove unsupported AIX native echo option -n by using printf#199395

Open
Himadhith wants to merge 1 commit into
llvm:mainfrom
Himadhith:himadhith/re-apply_echo_failure_fix
Open

[AIX] Re-apply: Remove unsupported AIX native echo option -n by using printf#199395
Himadhith wants to merge 1 commit into
llvm:mainfrom
Himadhith:himadhith/re-apply_echo_failure_fix

Conversation

@Himadhith
Copy link
Copy Markdown
Contributor

AIX native echo doesn't support the -n flag.
Use printf instead to ensure the test works across all systems and making it portable.

The current test fails as follows:

FAIL: lit :: unit/Util.py (1 of 1)
******************** TEST 'lit :: unit/Util.py' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
"/opt/freeware/bin/python3.12" /home/himadhit/llvm/community/build/utils/lit/tests/unit/Util.py
# executed command: /opt/freeware/bin/python3.12 /home/himadhit/llvm/community/build/utils/lit/tests/unit/Util.py
# .---command stderr------------
# | F..
# | ======================================================================
# | FAIL: test_basic (__main__.TestCommandCache.test_basic)
# | ----------------------------------------------------------------------
# | Traceback (most recent call last):
# |   File "/home/himadhit/llvm/community/build/utils/lit/tests/unit/Util.py", line 32, in test_basic
# |     self.assertEqual(lit_config.run_command_cached(["echo", "-n", "hi"]), b"hi")
# | AssertionError: b'-n hi\n' != b'hi'
# | 
# | ----------------------------------------------------------------------
# | Ran 3 tests in 2.092s
# | 
# | FAILED (failures=1)
# `-----------------------------
# error: command failed with exit status: 1

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-testing-tools

Author: Himadhith

Changes

AIX native echo doesn't support the -n flag.
Use printf instead to ensure the test works across all systems and making it portable.

The current test fails as follows:

FAIL: lit :: unit/Util.py (1 of 1)
******************** TEST 'lit :: unit/Util.py' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
"/opt/freeware/bin/python3.12" /home/himadhit/llvm/community/build/utils/lit/tests/unit/Util.py
# executed command: /opt/freeware/bin/python3.12 /home/himadhit/llvm/community/build/utils/lit/tests/unit/Util.py
# .---command stderr------------
# | F..
# | ======================================================================
# | FAIL: test_basic (__main__.TestCommandCache.test_basic)
# | ----------------------------------------------------------------------
# | Traceback (most recent call last):
# |   File "/home/himadhit/llvm/community/build/utils/lit/tests/unit/Util.py", line 32, in test_basic
# |     self.assertEqual(lit_config.run_command_cached(["echo", "-n", "hi"]), b"hi")
# | AssertionError: b'-n hi\n' != b'hi'
# | 
# | ----------------------------------------------------------------------
# | Ran 3 tests in 2.092s
# | 
# | FAILED (failures=1)
# `-----------------------------
# error: command failed with exit status: 1

Full diff: https://github.com/llvm/llvm-project/pull/199395.diff

1 Files Affected:

  • (modified) llvm/utils/lit/tests/unit/Util.py (+2-2)
diff --git a/llvm/utils/lit/tests/unit/Util.py b/llvm/utils/lit/tests/unit/Util.py
index 794950f44ef19..112ea59b869f5 100644
--- a/llvm/utils/lit/tests/unit/Util.py
+++ b/llvm/utils/lit/tests/unit/Util.py
@@ -29,12 +29,12 @@ def _lit_config():
     def test_basic(self):
         lit_config = self._lit_config()
 
-        self.assertEqual(lit_config.run_command_cached(["echo", "-n", "hi"]), b"hi")
+        self.assertEqual(lit_config.run_command_cached(["printf", "hi"]), b"hi")
         self.assertNotEqual(lit_config.run_command_cached("ls"), None)
 
         # Test that arguments (e.g. text=True) get forwarded to subprocess.run
         self.assertEqual(
-            lit_config.run_command_cached(["echo", "-n", "hi"], text=True), "hi"
+            lit_config.run_command_cached(["printf", "hi"], text=True), "hi"
         )
 
         # shell=True is not implied

Copy link
Copy Markdown
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants