-
Notifications
You must be signed in to change notification settings - Fork 5
add bash autograder #19
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis update introduces a Bash Arithmetic Lab, adding all necessary files for a basic multiplication scripting exercise. The changes include a README describing the assignment and requirements, a Bash script ( Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant math.sh
User->>math.sh: Run with -a <num1> -b <num2>
math.sh->>math.sh: Parse -a and -b options
math.sh->>math.sh: Compute product: num1 * num2
math.sh-->>User: Output result
sequenceDiagram
participant Autograder
participant test_autograder/tests.py
participant math.sh
Autograder->>test_autograder/tests.py: Load test cases
loop For each test case
Autograder->>math.sh: Run with test inputs
math.sh-->>Autograder: Output result
Autograder->>Autograder: Compare result to expected value
end
Autograder-->>User: Report results
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (7)
Bash-arith/autograde-Makefile (1)
1-9
: Add .PHONY forall
andclean
targets
Declaring these as.PHONY
prevents conflicts if files namedall
orclean
appear in the directory, improving Makefile robustness.+.PHONY: all clean all: tar xvf autograde.tar tar xvf handin.tar cp math.sh test_autograder (cd test_autograder; python3 driver.py) clean: rm -rf *~ test_autograder
Bash-arith/README.md (2)
4-9
: Specify language for the code block
Adding a language identifier (e.g.,bash
) to the fenced code block enables syntax highlighting and resolves the markdownlint MD040 warning.- ``` + ```bash ./math -a 1 -b 2 >>> 2 ./math -a 4 -b 8 >>> 32 - ``` + ```🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
4-4: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
11-12
: Fix typo in heading
Correct "Assesment" to "Assessment" for clarity.- ## Assesment Language + ## Assessment LanguageBash-arith/refsol/math.sh (2)
1-1
: Use a portable shebang
Recommend using#!/usr/bin/env bash
to ensure portability across environments where Bash may not reside in/usr/bin
.- #!/usr/bin/bash + #!/usr/bin/env bash
3-8
: Handle invalid options ingetopts
Adding a default*)
case will catch unexpected flags and provide a usage message, improving robustness.while getopts a:b: flag; do case "${flag}" in a) X=${OPTARG};; b) Y=${OPTARG};; + *) echo "Usage: $0 -a num -b num" >&2; exit 1;; esac done
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 5-8: Invalid flags are not handled. Add a *) case.
(SC2220)
Bash-arith/math.sh (2)
1-1
: Use a portable shebang
Switch to#!/usr/bin/env bash
for compatibility across different environments.- #!/usr/bin/bash + #!/usr/bin/env bash
3-8
: Handle invalid flags and ensure required arguments
Include a default*)
case for bad flags and validate that both-a
and-b
are provided before performing multiplication.while getopts a:b: flag; do case "${flag}" in a) X=${OPTARG};; b) Y=${OPTARG};; - esac + *) echo "Usage: $0 -a num -b num" >&2; exit 1;; + esac done + +# Verify both arguments are set +if [ -z "${X:-}" ] || [ -z "${Y:-}" ]; then + echo "Error: Both -a and -b arguments are required." >&2 + exit 1 +fi🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 5-8: Invalid flags are not handled. Add a *) case.
(SC2220)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
Bash-arith/autograde.tar
is excluded by!**/*.tar
,!**/*.tar
Bash-arith/refsol.tar
is excluded by!**/*.tar
,!**/*.tar
📒 Files selected for processing (5)
Bash-arith/README.md
(1 hunks)Bash-arith/autograde-Makefile
(1 hunks)Bash-arith/math.sh
(1 hunks)Bash-arith/refsol/math.sh
(1 hunks)Bash-arith/test_autograder/tests.py
(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
Bash-arith/README.md
4-4: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🪛 Shellcheck (0.10.0)
Bash-arith/math.sh
[warning] 5-8: Invalid flags are not handled. Add a *) case.
(SC2220)
Bash-arith/refsol/math.sh
[warning] 5-8: Invalid flags are not handled. Add a *) case.
(SC2220)
🔇 Additional comments (2)
Bash-arith/test_autograder/tests.py (1)
1-6
: Well-structured test cases
Thetests
list clearly defines descriptive labels and corresponding input-output triples, covering basic, zero, identity, and large-number scenarios. This will reliably validate the multiplication script.Bash-arith/autograde-Makefile (1)
1-9
: Autograder workflow looks correct
The sequence—extractingarchives, copying the student'smath.sh
, and invoking the Python driver—matches the intended autograding flow.
No description provided.