swadhin biswas ci(codecov): integrate test coverage reporting with token authentication Β· 10/17/2025
82cdfe1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env python3
"""
Test suite for ls-f column.py formatter
"""
import unittest
import subprocess
import tempfile
import os
import sys
from io import StringIO
# Add current directory to path to import column
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
class TestColumnFormatter(unittest.TestCase):
def setUp(self):
"""Set up test fixtures"""
self.test_input = "π dir\nπ script.py\nπ README.md\nπ data.csv\n"
self.column_script = os.path.join(os.path.dirname(__file__), 'column.py')
def run_column_py(self, input_text, env_vars=None):
"""Helper to run column.py with input"""
env = os.environ.copy()
if env_vars:
env.update(env_vars)
proc = subprocess.Popen(
['python3', self.column_script],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
text=True
)
stdout, stderr = proc.communicate(input_text)
return stdout, stderr, proc.returncode
def test_default_column_layout(self):
"""Test default column-major layout"""
stdout, stderr, returncode = self.run_column_py(self.test_input)
self.assertEqual(returncode, 0)
self.assertIn("π dir", stdout)
self.assertIn("π script.py", stdout)
def test_row_layout(self):
"""Test row-major layout with LSF_LAYOUT=rows"""
stdout, stderr, returncode = self.run_column_py(
self.test_input,
{'LSF_LAYOUT': 'rows'}
)
self.assertEqual(returncode, 0)
self.assertIn("π dir", stdout)
def test_custom_tabsize(self):
"""Test custom tab size"""
stdout, stderr, returncode = self.run_column_py(
self.test_input,
{'LSF_TABSIZE': '4'}
)
self.assertEqual(returncode, 0)
def test_empty_input(self):
"""Test with empty input"""
stdout, stderr, returncode = self.run_column_py("")
self.assertEqual(returncode, 0)
self.assertEqual(stdout.strip(), "")
def test_single_item(self):
"""Test with single item"""
stdout, stderr, returncode = self.run_column_py("π single.txt\n")
self.assertEqual(returncode, 0)
self.assertIn("π single.txt", stdout)
def test_many_items(self):
"""Test with many items"""
many_items = "\n".join([f"π file{i}.txt" for i in range(50)])
stdout, stderr, returncode = self.run_column_py(many_items)
self.assertEqual(returncode, 0)
self.assertIn("π file0.txt", stdout)
self.assertIn("π file49.txt", stdout)
def test_unicode_handling(self):
"""Test Unicode icon handling"""
unicode_input = "π΅ music.mp3\nπ¬ video.mp4\nπΌοΈ image.png\n"
stdout, stderr, returncode = self.run_column_py(unicode_input)
self.assertEqual(returncode, 0)
self.assertIn("π΅ music.mp3", stdout)
class TestLsfBasics(unittest.TestCase):
def setUp(self):
"""Set up test fixtures"""
self.lsf_script = os.path.join(os.path.dirname(__file__), 'lsf')
os.chmod(self.lsf_script, 0o755)
def run_lsf(self, args=None):
"""Helper to run lsf command"""
cmd = ['bash', self.lsf_script]
if args:
cmd.extend(args)
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
stdout, stderr = proc.communicate()
return stdout, stderr, proc.returncode
def test_version_flag(self):
"""Test --version flag"""
stdout, stderr, returncode = self.run_lsf(['--version'])
self.assertEqual(returncode, 0)
self.assertIn("4.5.1", stdout)
def test_help_flag(self):
"""Test --help flag"""
stdout, stderr, returncode = self.run_lsf(['--help'])
self.assertEqual(returncode, 0)
self.assertIn("Usage:", stdout)
self.assertIn("Options:", stdout)
def test_no_icons_flag(self):
"""Test --no-icons flag"""
stdout, stderr, returncode = self.run_lsf(['--no-icons'])
self.assertEqual(returncode, 0)
# Should run without icons, exit cleanly
def test_invalid_flag(self):
"""Test that lsf passes through flags to ls"""
stdout, stderr, returncode = self.run_lsf(['--invalid-flag'])
# lsf passes flags to ls, so ls will handle invalid flags
# The behavior depends on the ls implementation
# Just verify lsf doesn't crash internally
self.assertTrue(True) # If we get here, lsf didn't crash
if __name__ == '__main__':
unittest.main()