Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kmyk committed May 21, 2020
1 parent 85a6f9a commit 7c73ae1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions onlinejudge_verify/languages/cplusplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def _cplusplus_list_depending_files(path: pathlib.Path, *, CXX: pathlib.Path, jo
raise
with open(temp_file, 'rb') as fp:
data = fp.read()
makefile_rule = shlex.split(data.decode().replace('\\\n', ''), posix=not (is_windows))
return [pathlib.Path(path).resolve() for path in makefile_rule[1:]]
logger.debug('dependencies of %s: %s', str(path), repr(data))
makefile_rule = shlex.split(data.decode().strip().replace('\\\n', '').replace('\\\r\n', ''), posix=not is_windows)
return [pathlib.Path(path).resolve() for path in makefile_rule[1:]]


@functools.lru_cache(maxsize=None)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cplusplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_success(self) -> None:
def test_failure_with_backslash(self) -> None:
files = {
'main.cpp': textwrap.dedent("""\
#include ".\included.hpp"
#include ".\\included.hpp"
""").encode(),
'included.hpp': textwrap.dedent("""\
int main() {}
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@contextlib.contextmanager
def load_files(files: Dict[str, bytes]) -> Iterator[pathlib.Path]:
with tempfile.TemporaryDirectory() as tempdir_:
tempdir = pathlib.Path(tempdir_)
tempdir = pathlib.Path(tempdir_).resolve()
for relpath, data in files.items():
assert '/' not in relpath and '\\' not in relpath # we should use pathlib
path = tempdir / relpath
Expand Down

0 comments on commit 7c73ae1

Please sign in to comment.