Skip to content

Commit 6f3f0a7

Browse files
committed
change test_bundle.py to check the capability of including multiple paths
1 parent 4c3c826 commit 6f3f0a7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/test_bundle.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_smoke(self) -> None:
116116
self.assertEqual(subprocess.check_output([str(pathlib.Path('a.out').resolve())]), ('Hello World' + os.linesep).encode())
117117

118118
def test_complicated(self) -> None:
119-
library_files = {
119+
library_files_1 = {
120120
pathlib.Path('library', 'macro.hpp'): textwrap.dedent("""\
121121
#pragma once
122122
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
@@ -125,6 +125,8 @@ def test_complicated(self) -> None:
125125
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
126126
#define ALL(x) std::begin(x), std::end(x)
127127
""").encode(),
128+
}
129+
library_files_2 = {
128130
pathlib.Path('library', 'fibonacci.hpp'): textwrap.dedent("""\
129131
#pragma once
130132
#include <cstdint>
@@ -161,12 +163,13 @@ def test_complicated(self) -> None:
161163
with tempfile.TemporaryDirectory() as tempdir_dst_:
162164
tempdir_dst = pathlib.Path(tempdir_dst_)
163165

164-
with tests.utils.load_files_pathlib(library_files) as tempdir_src_library:
165-
with tests.utils.load_files_pathlib(test_files) as tempdir_src_test:
166-
with open(tempdir_dst / 'main.bundled.cpp', 'w') as fh:
167-
with contextlib.redirect_stdout(fh):
168-
args = ['-I', str(tempdir_src_library), str(tempdir_src_test / 'test' / 'main.cpp')]
169-
onlinejudge_bundle.main.main(args=args)
166+
with tests.utils.load_files_pathlib(library_files_1) as tempdir_src_library_1:
167+
with tests.utils.load_files_pathlib(library_files_2) as tempdir_src_library_2:
168+
with tests.utils.load_files_pathlib(test_files) as tempdir_src_test:
169+
with open(tempdir_dst / 'main.bundled.cpp', 'w') as fh:
170+
with contextlib.redirect_stdout(fh):
171+
args = ['-I', str(tempdir_src_library_1), '-I', str(tempdir_src_library_2), str(tempdir_src_test / 'test' / 'main.cpp')]
172+
onlinejudge_bundle.main.main(args=args)
170173

171174
# compile
172175
subprocess.check_call(['g++', '-o', str(tempdir_dst / 'a.out'), str(tempdir_dst / 'main.bundled.cpp')], stderr=sys.stderr)
@@ -207,4 +210,4 @@ def test_standard_headers(self) -> None:
207210
onlinejudge_bundle.main.main(args=args)
208211

209212
# compile
210-
subprocess.check_call(['g++', str(tempdir_dst / 'main.bundled.cpp')], stderr=sys.stderr)
213+
subprocess.check_call(['g++', str(tempdir_dst / 'main.bundled.cpp')], stderr=sys.stderr)

0 commit comments

Comments
 (0)