Skip to content
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

added test for 'detect versions from Nimble file' feature #106

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/setups.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,49 @@ proc buildGraph* =

exec "git tag v2.0.0"

proc buildGraphNoGitTags* =
createDir "source"
withDir "source":

createDir "proj_a"
withDir "proj_a":
exec "git init"
writeFile "proj_a.nimble", "version = \"1.0.0\"\n\nrequires \"proj_b >= 1.0.0\"\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update'"
writeFile "proj_a.nimble", "version = \"1.1.0\"\n\nrequires \"proj_b >= 1.1.0\"\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update'"

createDir "proj_b"
withDir "proj_b":
exec "git init"
writeFile "proj_b.nimble", "version = \"1.0.0\"\n\nrequires \"proj_c >= 1.0.0\"\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Initial commit for project B")

writeFile "proj_b.nimble", "version = \"1.1.0\"\n\nrequires \"proj_c >= 1.1.0\"\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Update proj_b.nimble for project B")

createDir "proj_c"
withDir "proj_c":
exec "git init"
writeFile "proj_c.nimble", "version = \"1.0.0\"\n\nrequires \"proj_d >= 1.2.0\"\n"
exec "git add proj_c.nimble"
exec "git commit -m " & quoteShell("Initial commit for project C")
writeFile "proj_c.nimble", "version = \"1.2.0\"\n\nrequires \"proj_d >= 1.0.0\"\n"
exec "git commit -am " & quoteShell("Update proj_c.nimble for project C")

createDir "proj_d"
withDir "proj_d":
exec "git init"
writeFile "proj_d.nimble", "version = \"1.0.0\"\n\n"
exec "git add proj_d.nimble"
exec "git commit -m " & quoteShell("Initial commit for project D")
writeFile "proj_d.nimble", "version = \"2.0.0\"\n\nrequires \"does_not_exist >= 1.2.0\"\n"
exec "git add proj_d.nimble"
exec "git commit -m " & quoteShell("broken version of package D")

when isMainModule:
buildGraph()
54 changes: 43 additions & 11 deletions tests/tester.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Small program that runs the test cases

import std / [strutils, os, osproc, sequtils, strformat]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'strformat' [UnusedImport]

Check warning on line 3 in tests/tester.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'sequtils' [UnusedImport]
from std/private/gitutils import diffFiles
import setups

Expand Down Expand Up @@ -40,6 +40,23 @@
[Info] (proj_d) [ ] (proj_d, 2.0.0)
[Info] (proj_d) [x] (proj_d, 1.0.0)
[Info] (../resolve) end of selection
"""

SemVerExpectedResultNoGitTags = """
[Info] (../resolve) selected:
[Info] (proj_a) [ ] (proj_a, #head)
[Info] (proj_a) [ ] (proj_a, 1.1.0)
[Info] (proj_a) [x] (proj_a, 1.0.0)
[Info] (proj_b) [ ] (proj_b, #head)
[Info] (proj_b) [ ] (proj_b, 1.1.0)
[Info] (proj_b) [x] (proj_b, 1.0.0)
[Info] (proj_c) [ ] (proj_c, #head)
[Info] (proj_c) [x] (proj_c, 1.2.0)
[Info] (proj_c) [ ] (proj_c, 1.0.0)
[Info] (proj_d) [ ] (proj_d, #head)
[Info] (proj_d) [ ] (proj_d, 2.0.0)
[Info] (proj_d) [x] (proj_d, 1.0.0)
[Info] (../resolve) end of selection
"""

MinVerExpectedResult = """selected:
Expand All @@ -53,17 +70,16 @@
end of selection
"""

proc testSemVer2() =
buildGraph()
proc testSemVer2(expected: string) =
createDir "semproject"
withDir "semproject":
let cmd = atlasExe & " --full --keepWorkspace --resolver=SemVer --colors:off --list use proj_a"
let (outp, status) = execCmdEx(cmd)
if status == 0:
if outp.contains SemVerExpectedResult:
if outp.contains expected:
discard "fine"
else:
echo "expected ", SemVerExpectedResult, " but got ", outp
echo "expected ", expected, " but got ", outp
raise newException(AssertionDefect, "Test failed!")
else:
echo "\n\n<<<<<<<<<<<<<<<< failed "
Expand All @@ -89,7 +105,22 @@

withDir "tests/ws_semver2":
try:
testSemVer2()
buildGraph()
testSemVer2(SemVerExpectedResult)
finally:
removeDir "does_not_exist"
removeDir "semproject"
removeDir "minproject"
removeDir "source"
removeDir "proj_a"
removeDir "proj_b"
removeDir "proj_c"
removeDir "proj_d"

withDir "tests/ws_semver2":
try:
buildGraphNoGitTags()
testSemVer2(SemVerExpectedResultNoGitTags)
finally:
removeDir "does_not_exist"
removeDir "semproject"
Expand Down Expand Up @@ -129,11 +160,12 @@
removeFile "nim.cfg"
removeFile "ws_integration.nimble"

withDir "tests/ws_integration":
try:
integrationTest()
finally:
when not defined(keepTestDirs):
cleanupIntegrationTest()
when not defined(quick):
withDir "tests/ws_integration":
try:
integrationTest()
finally:
when not defined(keepTestDirs):
cleanupIntegrationTest()

if failures > 0: quit($failures & " failures occurred.")
Loading