online-judge-tools/oj

`oj t -M all`でエラーが出る

hasegawa1 opened this issue · 2 comments

Summary / 概要

oj t -M allでエラーが出る

Steps to reproduce / 再現方法

  1. oj t -M all

environments:

  • version: 11.4.0
  • WSL2 上の Ubuntu 20.04

Expected behavior / 期待される挙動

適切に表示される

Actual behavior / 実際の挙動

[ERROR] 
Traceback (most recent call last):
  File "/home/xps15/.local/lib/python3.8/site-packages/onlinejudge_command/main.py", line 101, in main
    sys.exit(run_program(parsed, parser=parser))
  File "/home/xps15/.local/lib/python3.8/site-packages/onlinejudge_command/main.py", line 70, in run_program
    if not subcommand_test.run(args):
  File "/home/xps15/.local/lib/python3.8/site-packages/onlinejudge_command/subcommand/test.py", line 315, in run
    history += [test_single_case(name, paths['in'], paths.get('out'), args=args)]
  File "/home/xps15/.local/lib/python3.8/site-packages/onlinejudge_command/subcommand/test.py", line 253, in test_single_case
    status = display_result(proc, answer, memory, test_input_path, test_output_path, mle=args.mle, display_mode=DisplayMode(args.display_mode), does_print_input=args.print_input, silent=args.silent, match_result=match_result)
  File "/home/xps15/.local/lib/python3.8/site-packages/onlinejudge_command/subcommand/test.py", line 210, in display_result
    assert False
AssertionError

Other notes / その他

  • summary, diff は正しく表示されています
  • Will you try to create a pull request?
    • no

ここの場合分けが漏れているのが原因だと思います。

if display_mode == DisplayMode.SUMMARY:
logger.info(utils.NO_HEADER + 'output:\n%s', pretty_printers.make_pretty_large_file_content(answer.encode(), limit=40, head=20, tail=10, bold=True))
logger.info(utils.NO_HEADER + 'expected:\n%s', pretty_printers.make_pretty_large_file_content(expected.encode(), limit=40, head=20, tail=10, bold=True))
elif display_mode == DisplayMode.DIFF:
if max(answer.count('\n'), expected.count('\n')) <= 40:
pretty_printers.display_side_by_side_color(answer, expected)
else:
pretty_printers.display_snipped_side_by_side_color(answer, expected)
else:
assert False

このオプションを使おうとした理由は、printf デバッグなどで長い出力をしたいときにsummary や diff では途中が省略されてしまうからなので、all ですべて表示できるようになると嬉しいです。

普段は diff を使っているので表示行数を引数などで調整できると一番嬉しいのですが、diff 計算のことを考えると難しいのでしょうか?

kmyk commented

ここの場合分けが漏れているのが原因だと思います。

漏れてるどころかまったく未実装でした😇

普段は diff を使っているので表示行数を引数などで調整できると一番嬉しいのですが、diff 計算のことを考えると難しいのでしょうか?

難しいということはないのですが、現在の --display-mode=diff の実装があまりよくなくてテストがまったく書けていない (#891) ので、まずはリファクタリングから (たぶんすべて消して書きなおすのがよい) になります。面倒なのでやってなかったのですが、この機会にやりました (#893)