Skip to content

Commit

Permalink
Allow running blurb test from blurb-* directories (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Oct 11, 2024
2 parents 832ff64 + 984c4d2 commit ffafdfc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def save_next(self):
tests_run = 0

class TestParserPasses(unittest.TestCase):
directory = "blurb/tests/pass"
directory = "tests/pass"

def filename_test(self, filename):
b = Blurbs()
Expand All @@ -667,7 +667,7 @@ def test_files(self):


class TestParserFailures(TestParserPasses):
directory = "blurb/tests/fail"
directory = "tests/fail"

def filename_test(self, filename):
b = Blurbs()
Expand Down Expand Up @@ -820,6 +820,15 @@ def help(subcommand=None):
subcommands["--help"] = help


def _find_blurb_dir():
if os.path.isdir("blurb"):
return "blurb"
for path in glob.iglob("blurb-*"):
if os.path.isdir(path):
return path
return None


@subcommand
def test(*args):
"""
Expand All @@ -828,12 +837,13 @@ def test(*args):
# unittest.main doesn't work because this isn't a module
# so we'll do it ourselves

while not os.path.isdir("blurb"):
while (blurb_dir := _find_blurb_dir()) is None:
old_dir = os.getcwd()
os.chdir("..")
if old_dir == os.getcwd():
# we reached the root and never found it!
sys.exit("Error: Couldn't find the root of your blurb repo!")
os.chdir(blurb_dir)

print("-" * 79)

Expand Down

0 comments on commit ffafdfc

Please sign in to comment.