Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8ffeef1

Browse files
authored
Merge pull request #6 from ThomasChen0717/dev
Add support for Unix OS
2 parents 9f4ea0f + a4cd841 commit 8ffeef1

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

‎data/languages/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ set(CMAKE_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
3333
install(TARGETS solution_cpp
3434
CONFIGURATIONS Release
3535
RUNTIME DESTINATION ${CMAKE_INSTALL_DIR}
36-
)
36+
)

‎src/app/openleetcode.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
TESTCAST_OUTPUT_DIR = "testcase_output"
1919

2020
def run(command):
21-
result = subprocess.run(command.split(),
21+
if os.name == 'posix':
22+
result = subprocess.run(command,
23+
stdout=subprocess.PIPE,
24+
stderr=subprocess.STDOUT,
25+
shell=True)
26+
else:
27+
result = subprocess.run(command.split(),
2228
stdout=subprocess.PIPE,
2329
stderr=subprocess.STDOUT,
2430
shell=True)
@@ -159,7 +165,11 @@ def main():
159165
f"problem_builds_dir and problem arguments."))
160166
sys.exit(1)
161167

162-
exe_file = os.path.abspath(os.path.join(bin_dir,
168+
if os.name == 'posix':
169+
exe_file = os.path.abspath(os.path.join(bin_dir,
170+
f"solution_{args.language}"))
171+
else:
172+
exe_file = os.path.abspath(os.path.join(bin_dir,
163173
f"solution_{args.language}.exe"))
164174

165175
if not os.path.isfile(exe_file):

‎src/app/testrunner.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ def runTest(exec_filename, testcase_filename, output_filename):
6969
f"{os.path.abspath(output_filename)}"
7070
)
7171
logger.log(f"Running command: {command}")
72-
result = subprocess.run(command,
72+
if os.name == 'posix':
73+
result = subprocess.run(command,
74+
shell=True,
75+
cwd=os.path.dirname(exec_filename),
76+
timeout=PROBLEM_LTE_S,
77+
stderr=subprocess.PIPE)
78+
else:
79+
result = subprocess.run(command,
7380
shell=False,
7481
cwd=os.path.dirname(exec_filename),
7582
timeout=PROBLEM_LTE_S,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /