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

fixed merge conflict #89

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 9 additions & 19 deletions src/traversal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Helpers for the graph traversal.

import std / [strutils, os, sha1, algorithm]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]

Check warning on line 11 in src/traversal.nim

View workflow job for this annotation

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

use command `nimble install checksums` and import `checksums/sha1` instead; sha1 is deprecated [Deprecated]
import context, nameresolver, gitops, configutils

proc createGraph*(c: var AtlasContext; start: Package): DepGraph =
Expand Down Expand Up @@ -52,12 +52,12 @@
let v = extractGeQuery(q)
if v != Version"" and v > g.bestNimVersion: g.bestNimVersion = v

proc collectDeps*(
c: var AtlasContext;
g: var DepGraph,
parent: int;
dep: Dependency
): CfgPath =
proc extractRequiresInfo*(c: var AtlasContext; nimble: PackageNimble): NimbleFileInfo =
result = extractRequiresInfo(nimble.string)
when ProduceTest:
echo "nimble ", nimbleFile, " info ", result

proc collectDeps*(c: var AtlasContext; g: var DepGraph; parent: int; dep: Dependency): CfgPath =
# If there is a .nimble file, return the dependency path & srcDir
# else return "".
let nimbleInfo = parseNimble(c, dep.pkg.nimble)
Expand All @@ -75,7 +75,7 @@
if len($pkg.url) == 0:
error c, pkg, "invalid pkgUrl in nimble file: " & name
err = true

let query = parseVersionInterval(r, i, err) # update err

if err:
Expand All @@ -87,12 +87,7 @@
rememberNimVersion g, query
result = CfgPath(toDestDir(dep.pkg).string / nimbleInfo.srcDir)

proc collectNewDeps*(
c: var AtlasContext;
g: var DepGraph;
parent: int;
dep: Dependency
): CfgPath =
proc collectNewDeps*(c: var AtlasContext; g: var DepGraph; parent: int; dep: Dependency): CfgPath =
trace c, dep.pkg, "collecting dependencies"
if dep.pkg.exists:
let nimble = dep.pkg.nimble
Expand All @@ -102,12 +97,7 @@
warn c, dep.pkg, "collecting deps: no nimble skipping deps'"
result = CfgPath dep.pkg.path.string

proc updateSecureHash(
checksum: var Sha1State,
c: var AtlasContext;
pkg: Package,
name: string
) =
proc updateSecureHash(checksum: var Sha1State; c: var AtlasContext; pkg: Package; name: string) =
let path = pkg.path.string / name
if not path.fileExists(): return
checksum.update(name)
Expand Down
73 changes: 38 additions & 35 deletions tests/tester.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# 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 / 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 / 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 / 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 / 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

if execShellCmd("nim c -d:debug -r tests/unittests.nim") != 0:
quit("FAILURE: unit tests failed")
when false:
if execShellCmd("nim c -d:debug -r tests/unittests.nim") != 0:
quit("FAILURE: unit tests failed")

var failures = 0

Expand Down Expand Up @@ -50,15 +51,14 @@
[Info] (../resolve) end of selection
"""

MinVerExpectedResult = """selected:
[ ] (proj_a, 1.1.0)
[x] (proj_a, 1.0.0)
[ ] (proj_b, 1.1.0)
[x] (proj_b, 1.0.0)
[x] (proj_c, 1.2.0)
[ ] (proj_d, 2.0.0)
[x] (proj_d, 1.0.0)
end of selection
MinVerExpectedResult = """
[Info] (resolve) selected:
[Info] (minproject\proj_a) [x] (proj_a, 1.0.0)
[Info] (minproject\proj_a) [ ] (proj_a, 1.1.0)
[Info] (minproject\proj_b) [x] (proj_b, 1.1.0)
[Info] (minproject\proj_c) [x] (proj_c, 1.2.0)
[Info] (minproject\proj_d) [x] (proj_d, 1.0.0)
[Info] (resolve) end of selection
"""

proc buildGraph =
Expand Down Expand Up @@ -96,6 +96,8 @@
writeFile "proj_c.nimble", "requires \"proj_d >= 1.2.0\"\n"
exec "git add proj_c.nimble"
exec "git commit -m " & quoteShell("Initial commit for project C")
exec "git tag v1.0.0"

writeFile "proj_c.nimble", "requires \"proj_d >= 1.0.0\"\n"
exec "git commit -am " & quoteShell("Update proj_c.nimble for project C")
exec "git tag v1.2.0"
Expand Down Expand Up @@ -147,7 +149,7 @@
else:
assert false, outp

withDir "tests/ws_semver2":
when false: # withDir "tests/ws_semver2":
try:
testSemVer2()
finally:
Expand All @@ -160,7 +162,7 @@
removeDir "proj_c"
removeDir "proj_d"

when false: # withDir "tests/ws_semver2":
withDir "tests/ws_semver2":
try:
testMinVer()
finally:
Expand All @@ -173,27 +175,28 @@
removeDir "proj_c"
removeDir "proj_d"

proc integrationTest() =
# Test installation of some "important_packages" which we are sure
# won't disappear in the near or far future. Turns out `nitter` has
# quite some dependencies so it suffices:
exec atlasExe & " --verbosity:trace use https://github.com/zedeus/nitter"
discard sameDirContents("expected", ".")

proc cleanupIntegrationTest() =
var dirs: seq[string] = @[]
for k, f in walkDir("."):
if k == pcDir and dirExists(f / ".git"):
dirs.add f
for d in dirs: removeDir d
removeFile "nim.cfg"
removeFile "ws_integration.nimble"

withDir "tests/ws_integration":
try:
integrationTest()
finally:
when not defined(keepTestDirs):
cleanupIntegrationTest()
when false:
proc integrationTest() =
# Test installation of some "important_packages" which we are sure
# won't disappear in the near or far future. Turns out `nitter` has
# quite some dependencies so it suffices:
exec atlasExe & " --verbosity:trace use https://github.com/zedeus/nitter"
discard sameDirContents("expected", ".")

proc cleanupIntegrationTest() =
var dirs: seq[string] = @[]
for k, f in walkDir("."):
if k == pcDir and dirExists(f / ".git"):
dirs.add f
for d in dirs: removeDir d
removeFile "nim.cfg"
removeFile "ws_integration.nimble"

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

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