nip/tests/test_recipes.nim

56 lines
1.2 KiB
Nim

## Test recipe parsing
import std/[options]
import ../src/nimpak/build/recipe_parser
proc testRecipe(recipePath: string): bool =
echo "\nTesting recipe: ", recipePath
let recipeOpt = parseRecipeFile(recipePath)
if recipeOpt.isNone():
echo " ✗ Failed to parse recipe"
return false
let recipe = recipeOpt.get()
echo " ✓ Parsed successfully"
echo " Name: ", recipe.name
echo " Version: ", recipe.version
echo " Tool Type: ", recipe.toolType
echo " Platforms: ", recipe.platforms.len
let (valid, errors) = validateRecipe(recipe)
if not valid:
echo " ✗ Validation failed:"
for error in errors:
echo " - ", error
return false
echo " ✓ Validation passed"
return true
proc main() =
echo "Recipe Parser Tests"
echo "==================="
var allPassed = true
if not testRecipe("../recipes/nix/minimal-nix.kdl"):
allPassed = false
if not testRecipe("../recipes/pkgsrc/minimal-pkgsrc.kdl"):
allPassed = false
if not testRecipe("../recipes/gentoo/minimal-gentoo.kdl"):
allPassed = false
echo ""
if allPassed:
echo "✓ All tests passed!"
quit(0)
else:
echo "✗ Some tests failed"
quit(1)
when isMainModule:
main()