Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add bash autograder #19

wants to merge 1 commit into from

Conversation

lmaosoggypancakes
Copy link

No description provided.

Copy link

coderabbitai bot commented Apr 20, 2025

📝 Walkthrough

Walkthrough

This 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 (math.sh) that multiplies two numbers provided via command-line flags, a Makefile for autograding setup and execution, a reference solution script, and a Python file containing test cases for autograding. No existing files are modified, and no public APIs or exported entities are altered.

Changes

File(s) Change Summary
Bash-arith/README.md New README added detailing the lab assignment, usage examples, submission requirements, and environment details.
Bash-arith/autograde-Makefile New Makefile for extracting archives, copying the script, running the autograder, and cleaning up artifacts.
Bash-arith/math.sh New Bash script that multiplies two numbers provided with -a and -b flags and prints the result.
Bash-arith/refsol/math.sh Reference solution script added, functionally identical to the main script, for multiplication via flags.
Bash-arith/test_autograder/tests.py New Python file defining a list of test cases for use in autograding the Bash script.

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
Loading
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
Loading

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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 for all and clean targets
Declaring these as .PHONY prevents conflicts if files named all or clean 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 Language
Bash-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 in getopts
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

📥 Commits

Reviewing files that changed from the base of the PR and between cb5acdc and 75fb8ed.

⛔ 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
The tests 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's math.sh, and invoking the Python driver—matches the intended autograding flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant