Skip to content

Commit

Permalink
[spec/stateful/job-control] Mark pipeline suspend/resume N-I
Browse files Browse the repository at this point in the history
It's not implemented, and this is documented in "Known Differences".

The reason is that OSH uses the zsh-like 'lastpipe' behavior.

Related to issue #1087.
  • Loading branch information
Andy C committed Aug 1, 2023
1 parent 4a7e541 commit a9ed51e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
37 changes: 26 additions & 11 deletions spec/stateful/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ def stop_process__hack(name, sig_num=signal.SIGSTOP):
# Mutated by each test file.
CASES = []

def register(skip_shells=None):
if skip_shells is None:
skip_shells = []
def register(skip_shells=None, not_impl_shells=None):
skip_shells = skip_shells or []
not_impl_shells = not_impl_shells or []

def decorator(func):
CASES.append((func.__doc__, func, skip_shells))
CASES.append((func.__doc__, func, skip_shells, not_impl_shells))
return func
return decorator


class Result(object):
SKIP = 1
OK = 2
FAIL = 3
NI = 2
OK = 3
FAIL = 4


class TestRunner(object):
Expand Down Expand Up @@ -135,26 +136,35 @@ def RunCase(self, shell_path, shell_label, func):
raise AssertionError(result)

def RunCases(self, cases, case_predicate, shell_pairs, result_table, flaky):
for case_num, (desc, func, skip_shells) in enumerate(cases):
for case_num, (desc, func, skip_shells, not_impl_shells) in enumerate(cases):
if not case_predicate(case_num, desc):
continue

result_row = [case_num]

for shell_label, shell_path in shell_pairs:
skip = shell_label in skip_shells
skip_str = 'SKIP' if skip else ''
skip_str = ''
if shell_label in skip_shells:
skip_str = 'SKIP'
if shell_label in not_impl_shells:
skip_str = 'N-I'

print()
print('%s\t%d\t%s\t%s' % (skip_str, case_num, shell_label, desc))
print()
sys.stdout.flush() # prevent interleaving

if skip:
if shell_label in skip_shells:
result_row.append(Result.SKIP)
flaky[case_num, shell_label] = -1
continue

# N-I is just like SKIP, but it's displayed differently
if shell_label in not_impl_shells:
result_row.append(Result.NI)
flaky[case_num, shell_label] = -1
continue

result, retries = self.RunCase(shell_path, shell_label, func)
flaky[case_num, shell_label] = retries

Expand Down Expand Up @@ -217,6 +227,9 @@ def PrintResults(shell_pairs, result_table, flaky, num_retries, f):
if cell == Result.SKIP:
f.write('SKIP\t')

elif cell == Result.NI:
f.write('N-I\t')

elif cell == Result.FAIL:
# Don't count C++ failures right now
if shell_label != 'osh-cpp':
Expand Down Expand Up @@ -317,7 +330,7 @@ def main(argv):

# List test cases and return
if opts.do_list:
for i, (desc, _, _) in enumerate(CASES):
for i, (desc, _, _, _) in enumerate(CASES):
print('%d\t%s' % (i, desc))
return

Expand Down Expand Up @@ -370,3 +383,5 @@ def main(argv):
except RuntimeError as e:
print('FATAL: %s' % e, file=sys.stderr)
sys.exit(1)

# vim: sw=2
9 changes: 7 additions & 2 deletions spec/stateful/job_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,14 @@ def stopped_process(sh):
expect_no_job(sh)


@register()
# OSH doesn't support this because of the lastpipe issue
# Note: it would be nice to print a message on Ctrl-Z like zsh does:
# "job can't be suspended"

@register(not_impl_shells=['osh', 'osh-cpp'])
def stopped_pipeline(sh):
'Resuming a stopped pipeline (issue 1087)'
'Suspend and resume a pipeline (issue 1087)'

expect_prompt(sh)

sh.sendline('sleep 10 | cat | cat')
Expand Down
2 changes: 1 addition & 1 deletion test/stateful.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interactive() {
}

job-control() {
spec/stateful/job_control.py $FIRST --oils-failures-allowed 1 "$@"
spec/stateful/job_control.py $FIRST --oils-failures-allowed 0 "$@"
}

# Run on just 2 shells
Expand Down

0 comments on commit a9ed51e

Please sign in to comment.