Skip to content

Commit

Permalink
indicates stdout files and stderr files to failed cases
Browse files Browse the repository at this point in the history
and fix --timeout to seconds
  • Loading branch information
TimeExceed committed Jun 10, 2022
1 parent d53c920 commit 4505821
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions python/testa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,11 @@ def broken_throw():
empty = {}
empty['xxx']


@testa.is_(expect=None)
def sleep_case():
from time import sleep
sleep(3)

if __name__ == '__main__':
testa.main()
13 changes: 8 additions & 5 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def parseArgs():
help='A regular expression. Only test cases matching this pattern will be run. [default: ".*"]')
parser.add_argument('-e', '--exclude', nargs='?', default='^$',
help='A regular expression. Test cases matching this pattern will not be run. [default: "^$"]')
parser.add_argument('--timeout', nargs='?',
help='how long a case is allowed to run (in msec) [default: disable]')
parser.add_argument('--timeout', nargs='?', type=int,
help='how long a case is allowed to run (in sec) [default: disable]')
parser.add_argument('--report', nargs='?',
help='report as a json file')
args = parser.parse_args()
Expand Down Expand Up @@ -117,8 +117,8 @@ def work(opts, qin, qout):
kws['stderr'] = stderr
kws['check'] = True
kws['cwd'] = cs['cwd']
if opts.timeout:
kws['timeout'] = opts.timeout / 1000
if opts.timeout and not cs.get('suppress_timeout', False):
kws['timeout'] = opts.timeout
cs['start'] = datetime.utcnow()
try:
subprocess.run(args, **kws)
Expand Down Expand Up @@ -181,7 +181,8 @@ def collectCases(opts, langs, reqQ, resQ):
'execute': exeArgs,
'cwd': progDir,
'stdout': op.join(testDir, 'cases.out'),
'stderr': op.join(testDir, 'cases.err')})
'stderr': op.join(testDir, 'cases.err'),
'suppress_timeout': True})
for e in exes:
reqQ.put(e)

Expand Down Expand Up @@ -295,6 +296,8 @@ def report(filename, results):
print('%d failed' % len(failed))
for x in failed:
print(x['name'])
print(' stdout:', x['stdout'])
print(' stderr:', x['stderr'])
if opts.report:
report(opts.report, passed + failed)
print()
Expand Down

0 comments on commit 4505821

Please sign in to comment.