Skip to content

Commit edd1945

Browse files
committed
[ignoring-somethings] Add more verifications
1 parent a54b965 commit edd1945

File tree

5 files changed

+65
-13
lines changed

5 files changed

+65
-13
lines changed

ignoring_somethings/tests/specs/base.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: new-file
8+
filename: .gitignore
9+
contents: |
10+
many/*
11+
why_am_i_hidden.txt
12+
- type: add
13+
files:
14+
- .gitignore
15+
- type: commit
16+
message: Add .gitignore
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: new-file
8+
filename: .gitignore
9+
contents: |
10+
many/*
11+
!many/file22.txt
12+
ignore_me.txt
13+
this/**/runaway.txt
14+
- type: add
15+
files:
16+
- .gitignore
17+
- type: commit
18+
message: Add .gitignore
Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
1-
from git_autograder import GitAutograderTestLoader
1+
from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output
22

3-
from ..verify import verify
3+
from ..verify import (
4+
NOT_IGNORING_IGNORE_ME,
5+
NOT_IGNORING_RUNAWAY,
6+
STILL_HIDING,
7+
STILL_IGNORING_FILE_22,
8+
verify,
9+
)
410

511
REPOSITORY_NAME = "ignoring-somethings"
612

713
loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify)
814

915

10-
def test():
11-
with loader.load("specs/base.yml", "start"):
12-
pass
16+
def test_valid():
17+
with loader.load("specs/valid.yml", "start") as output:
18+
assert_output(
19+
output,
20+
GitAutograderStatus.SUCCESSFUL,
21+
["Great work using .gitignore!"],
22+
)
23+
24+
25+
def test_no_change():
26+
with loader.load("specs/no_change.yml", "start") as output:
27+
assert_output(
28+
output,
29+
GitAutograderStatus.UNSUCCESSFUL,
30+
[
31+
STILL_IGNORING_FILE_22,
32+
STILL_HIDING,
33+
NOT_IGNORING_IGNORE_ME,
34+
NOT_IGNORING_RUNAWAY,
35+
],
36+
)

ignoring_somethings/verify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from typing import List
23

34
from git_autograder import GitAutograderOutput, GitAutograderRepo, GitAutograderStatus
@@ -25,13 +26,12 @@ def verify(repo: GitAutograderRepo) -> GitAutograderOutput:
2526
main_branch.latest_commit.checkout()
2627

2728
# Read the file and parse it
28-
with open(".gitignore", "r") as gitignore_file:
29+
with open(os.path.join(repo.repo_path, ".gitignore"), "r") as gitignore_file:
2930
lines = [
3031
line.strip() for line in gitignore_file.readlines() if line.strip() != ""
3132
]
3233

3334
comments: List[str] = []
34-
print(lines)
3535
if "!many/file22.txt" not in lines:
3636
comments.append(STILL_IGNORING_FILE_22)
3737

0 commit comments

Comments
 (0)