Skip to content

Automated PR: aether-bot-17-03-25-9pm-18-09 #3

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,34 @@ fi
FILE_EXTENSION="$1"
CODE_FILE="/usr/src/app/cpp-engine/app/main.${FILE_EXTENSION}"

# Check if the code file exists
if [ ! -f "$CODE_FILE" ]; then
echo "Error: Code file '$CODE_FILE' not found."
exit 1
fi

if [ "$FILE_EXTENSION" == "c" ]; then
clang -o output_program "$CODE_FILE" 2> compile_error.txt
elif [ "$FILE_EXTENSION" == "cpp" ]; then
clang++ -o output_program "$CODE_FILE" 2> compile_error.txt
else
echo "Error: Invalid language specified. Use 'c' or 'cpp'."
exit 1
fi

# Check if there were any compilation errors
if [ $? -ne 0 ]; then
echo -e "Compilation failed!\n"
cat compile_error.txt
exit 1
fi
# Run the compiled program and capture runtime errors
./output_program > output.txt 2> runtime_error.txt

# Check if there were any runtime errors
if [ $? -ne 0 ]; then
echo -e "Runtime error!\n"
cat runtime_error.txt
# Check if the compiled program exists
if [ ! -f "output_program" ]; then
echo "Error: Compilation did not produce an executable."
exit 1

fi

# start
if [ -f "/usr/src/app/cpp-engine/app/input.txt" ]; then
# Run the compiled program with input redirection
Expand All @@ -41,7 +47,10 @@ else
./output_program > output.txt 2> runtime_error.txt
fi
# end

# Check if there were any runtime errors
if [ $? -ne 0 ]; then
echo -e "Runtime error!\n"
cat runtime_error.txt
exit 1
fi
Expand Down