Fixed run_cmd to account for empty stdout
On Linux, a successful compile does not produce any standard out, which is what I was implicitly expecting. I added a dummy value for stdout if the command is successful, which ensures that even when the compiler produces no output, we still look like a success.
This commit is contained in:
@@ -455,7 +455,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 111,
|
||||
"execution_count": 113,
|
||||
"id": "e42286bc-085c-45dc-b101-234308e58269",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -477,7 +477,7 @@
|
||||
"def run_cmd(command_to_run):\n",
|
||||
" try:\n",
|
||||
" run_result = subprocess.run(command_to_run, check=True, text=True, capture_output=True)\n",
|
||||
" return run_result.stdout\n",
|
||||
" return run_result.stdout if run_result.stdout else \"SUCCESS\"\n",
|
||||
" except:\n",
|
||||
" return \"\"\n",
|
||||
"\n",
|
||||
@@ -513,7 +513,7 @@
|
||||
" elif my_platform == \"Linux\":\n",
|
||||
" if os.path.isfile(\"./simple\"):\n",
|
||||
" os.remove(\"./simple\")\n",
|
||||
" compile_cmd = [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]\n",
|
||||
" compile_cmd = [\"g++\", \"simple.cpp\", \"-o\", \"simple\"]\n",
|
||||
" if run_cmd(compile_cmd):\n",
|
||||
" if run_cmd([\"./simple\"]) == \"Hello\":\n",
|
||||
" my_compiler = [\"Linux\", \"GCC\", [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]]\n",
|
||||
|
||||
Reference in New Issue
Block a user