Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Jun 5, 2024
1 parent 0593149 commit 3ff935b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions git_fleximod/git_fleximod.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ def submodules_status(gitmodules, root_dir, toplevel=False):
# submodule commands use path, not name
url = url.replace("[email protected]:", "https://github.com/")
tags = rootgit.git_operation("ls-remote", "--tags", url)
ahash = rootgit.git_operation("submodule","status",newpath).split()[0][1:]
result = rootgit.git_operation("submodule","status",newpath).split()
ahash = None
if result:
ahash = result[0][1:]
hhash = None
atag = None
needsupdate += 1
Expand All @@ -307,7 +310,7 @@ def submodules_status(gitmodules, root_dir, toplevel=False):
for htag in tags.split("\n"):
if htag.endswith('^{}'):
htag = htag[:-3]
if not atag and ahash in htag:
if ahash and not atag and ahash in htag:
atag = (htag.split()[1])[10:]
if tag and not hhash and htag.endswith(tag):
hhash = htag.split()[0]
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def logger():
"submodule_name": "test_optional",
"status1" : "test_optional MPIserial_2.5.0-3-gd82ce7c is out of sync with .gitmodules MPIserial_2.4.0",
"status2" : "test_optional at tag MPIserial_2.4.0",
"status3" : "test_optional not checked out, aligned at tag MPIserial_2.4.0",
"status3" : "test_optional not checked out, out of sync at tag None, expected tag is MPIserial_2.4.0",
"status4" : "test_optional at tag MPIserial_2.4.0",
"gitmodules_content": """
[submodule "test_optional"]
Expand All @@ -46,7 +46,7 @@ def logger():
"submodule_name": "test_alwaysoptional",
"status1" : "test_alwaysoptional MPIserial_2.3.0 is out of sync with .gitmodules e5cf35c",
"status2" : "test_alwaysoptional at hash e5cf35c",
"status3" : "test_alwaysoptional not checked out, out of sync at tag MPIserial_2.3.0",
"status3" : "out of sync at tag None, expected tag is e5cf35c",
"status4" : "test_alwaysoptional at hash e5cf35c",
"gitmodules_content": """
[submodule "test_alwaysoptional"]
Expand Down
5 changes: 2 additions & 3 deletions tests/test_d_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_complex_checkout(git_fleximod, complex_repo, logger):
assert("ToplevelRequired not checked out, aligned at tag MPIserial_2.5.0" in status.stdout)
assert("AlwaysRequired not checked out, aligned at tag MPIserial_2.4.0" in status.stdout)
assert("Complex not checked out, aligned at tag testtag02" in status.stdout)
assert("AlwaysOptional not checked out, aligned at tag MPIserial_2.3.0" in status.stdout)
assert("AlwaysOptional not checked out, out of sync at tag None, expected tag is MPIserial_2.3.0" in status.stdout)

# This should checkout and update test_submodule and complex_sub
result = git_fleximod(complex_repo, "update")
Expand Down Expand Up @@ -40,8 +40,7 @@ def test_complex_checkout(git_fleximod, complex_repo, logger):
assert("ToplevelRequired at tag MPIserial_2.5.0" in status.stdout)
assert("AlwaysRequired at tag MPIserial_2.4.0" in status.stdout)
assert("Complex at tag testtag02" in status.stdout)
assert("AlwaysOptional not checked out, aligned at tag MPIserial_2.3.0" in status.stdout)

assert("AlwaysOptional not checked out, out of sync at tag None, expected tag is MPIserial_2.3.0" in status.stdout)

# Finally update optional
result = git_fleximod(complex_repo, "update --optional")
Expand Down

0 comments on commit 3ff935b

Please sign in to comment.