Skip to content

Commit a053a30

Browse files
author
Theofilos Manitaras
committed
Add unittest
1 parent ac04f69 commit a053a30

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
import os
5+
if sys.stdin.isatty():
6+
print("stdin is a tty")
7+
# do some tty-only thing
8+
print(os.tcgetpgrp(sys.stdin.fileno()))
9+
else:
10+
print("stdin is not a tty")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import reframe as rfm
2+
import reframe.utility.sanity as sn
3+
4+
5+
@rfm.simple_test
6+
class TestBuggyStdin(rfm.RunOnlyRegressionTest):
7+
descr = 'Test that stdin is not a tty'
8+
valid_systems = ['*']
9+
valid_prog_environs = ['*']
10+
executable = './test.py'
11+
12+
@sanity_function
13+
def assert_stdin_not_a_tty(self):
14+
return sn.assert_found('stdin is not a tty', self.stdout)

unittests/test_cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,3 +917,13 @@ def test_fixture_resolution(run_reframe):
917917
action='run'
918918
)
919919
assert returncode == 0
920+
921+
922+
def test_check_stdin_not_a_tty(run_reframe, tmp_path):
923+
returncode, stdout, stderr = run_reframe(
924+
checkpath=[
925+
'unittests/resources/checks_unlisted/test_stdin_not_a_tty.py'
926+
])
927+
assert 'PASSED' in stdout
928+
assert 'FAILED' not in stdout
929+
assert returncode == 0

0 commit comments

Comments
 (0)