Skip to content

Commit

Permalink
Merge pull request #869 from online-judge-tools/mac-gtime
Browse files Browse the repository at this point in the history
Use "gtime" for GNU time on macOS
  • Loading branch information
kmyk authored Apr 9, 2021
2 parents 68294cc + 934a563 commit 9cd719a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion onlinejudge_command/subcommand/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import os
import pathlib
import platform
import subprocess
import tempfile
import threading
Expand Down Expand Up @@ -50,7 +51,7 @@ def add_subparser(subparsers: argparse.Action) -> None:
subparser.add_argument('--no-print-input', action='store_false', dest='print_input')
subparser.add_argument('-j', '--jobs', metavar='N', type=int, help='specifies the number of jobs to run simultaneously (default: no parallelization)')
subparser.add_argument('--print-memory', action='store_true', help='print the amount of memory which your program used, even if it is small enough')
subparser.add_argument('--gnu-time', help='used to measure memory consumption (default: "time")', default='time')
subparser.add_argument('--gnu-time', help='used to measure memory consumption (default: "time" on Linux, "gtime" on mac)', default=None)
subparser.add_argument('--no-ignore-backup', action='store_false', dest='ignore_backup')
subparser.add_argument('--ignore-backup', action='store_true', help='ignore backup files and hidden files (i.e. files like "*~", "\\#*\\#" and ".*") (default)')
subparser.add_argument('--log-file', type=pathlib.Path, help=argparse.SUPPRESS)
Expand Down Expand Up @@ -294,8 +295,15 @@ def run(args: 'argparse.Namespace') -> int:
tests = fmtutils.construct_relationship_of_files(args.test, args.directory, args.format)

# check wheather GNU time is available
if args.gnu_time is None:
if platform.system() == 'Darwin':
args.gnu_time = 'gtime'
else:
args.gnu_time = 'time'
if not check_gnu_time(args.gnu_time):
logger.warning('GNU time is not available: %s', args.gnu_time)
if platform.system() == 'Darwin':
logger.info(utils.HINT + 'You can install GNU time with: $ brew install gnu-time')
args.gnu_time = None
if args.mle is not None and args.gnu_time is None:
raise RuntimeError('--mle is used but GNU time does not exist')
Expand Down

0 comments on commit 9cd719a

Please sign in to comment.