comparison tests/test_resources.nim @ 1139:114f395b9144

did: finish refactoring and updated all tests accordingly
author sam <sam@basx.dev>
date Sat, 08 Jun 2024 14:58:25 +0700
parents 1ab09f8cc68d
children
comparison
equal deleted inserted replaced
1138:02e1d2658ff5 1139:114f395b9144
4 import std/strutils 4 import std/strutils
5 5
6 import semicongine 6 import semicongine
7 7
8 proc list_all_mods_all_files() = 8 proc list_all_mods_all_files() =
9 for package in packages(): 9 for package in Packages():
10 echo &"Files in package {package}:" 10 echo &"Files in package {package}:"
11 for i in walkResources(package = package): 11 for i in WalkResources(package = package):
12 echo " ", i, ": ", i.loadResource(package = package).readAll().len 12 echo " ", i, ": ", i.LoadResource(package = package).readAll().len
13 13
14 proc print_ls(dir, package: string, indent = 2) = 14 proc print_ls(dir, package: string, indent = 2) =
15 for i in dir.ls(package = package): 15 for i in dir.List(package = package):
16 if i.kind == pcDir: 16 if i.kind == pcDir:
17 echo "".align(indent), i.path, "/" 17 echo "".align(indent), i.path, "/"
18 print_ls(dir.joinPath(i.path), package = package, indent = indent + 2) 18 print_ls(dir.joinPath(i.path), package = package, indent = indent + 2)
19 else: 19 else:
20 echo "".align(indent), i.path, ": ", dir.joinPath(i.path).loadResource(package = package).readAll().len 20 echo "".align(indent), i.path, ": ", dir.joinPath(i.path).LoadResource(package = package).readAll().len
21 21
22 proc list_files() = 22 proc list_files() =
23 for package in packages(): 23 for package in Packages():
24 echo &"Recursive walk of package {package}: " 24 echo &"Recursive walk of package {package}: "
25 print_ls("", package = package) 25 print_ls("", package = package)
26 26
27 27
28 proc main() = 28 proc main() =
29 echo "Packages available: ", packages() 29 echo "Packages available: ", Packages()
30 list_all_mods_all_files() 30 list_all_mods_all_files()
31 list_files() 31 list_files()
32 32
33 when isMainModule: 33 when isMainModule:
34 main() 34 main()