-
Notifications
You must be signed in to change notification settings - Fork 308
Fix language autodetection #1241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
174acc5
a437721
a1f7e83
75852f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,8 @@ def by_ext(ext: str) -> Any: | |
| if name.lower() == ext: | ||
| return executor | ||
|
|
||
| for executor in sorted(executors.values(), key=lambda executor: executor.Executor.name): | ||
| if executor.Executor.ext == ext: | ||
| for executor in sorted(executors.values(), key=lambda executor: executor.Executor.ext_priority, reverse=True): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we specify a fixed order? Like lexicographically increasing by executor name? I don't want any flaky behaviour and dict value order isn't guaranteed... |
||
| if ext in executor.Executor.get_valid_exts(): | ||
| return executor | ||
|
|
||
| raise KeyError('no executor for extension "%s"' % ext) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| import sys | ||
| import tempfile | ||
| import traceback | ||
| from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union | ||
| from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, Union | ||
|
|
||
| from dmoj.cptbox import IsolateTracer, TracedPopen, syscalls | ||
| from dmoj.cptbox.filesystem_policies import ExactDir, ExactFile, FilesystemAccessRule, RecursiveDir | ||
|
|
@@ -120,6 +120,7 @@ class BaseExecutor(metaclass=ExecutorMeta): | |
| test_memory = env.selftest_memory_limit | ||
| version_regex = re.compile(r'.*?(\d+(?:\.\d+)+)', re.DOTALL) | ||
| source_filename_format = '{problem_id}.{ext}' | ||
| ext_priority = 0 # When there are multiple versions of a similar runtime, bigger is newer | ||
|
|
||
| address_grace = 65536 | ||
| data_grace = 0 | ||
|
|
@@ -483,3 +484,12 @@ def get_find_first_mapping(cls) -> Optional[Dict[str, List[str]]]: | |
| @classmethod | ||
| def autoconfig(cls) -> AutoConfigOutput: | ||
| return cls.autoconfig_find_first(cls.get_find_first_mapping()) | ||
|
|
||
| @classmethod | ||
| def get_valid_exts(cls) -> Sequence[str]: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why this is a method and not just a class variable? |
||
| # This exists because sometimes we want to recognize more extensions than just `ext` for auxiliary files | ||
| return (cls.ext,) | ||
|
|
||
| @classmethod | ||
| def supports_multifile(cls) -> bool: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, class variable. |
||
| return False | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| bool is_valid(int n) { return n == 1; } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| language: CLANG | ||
| time: 2 | ||
| memory: 65536 | ||
| source: sigtest.c | ||
| expect: AC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a smarter numbering scheme? Like 111 for Clang C11, 10099 for GCC C99, 10111 for C11, 11114 for C++14, etc.? This way, we don't need to shuffle all the numbers to add a new runtime...