/****************************************************************************** __ ____ __ / / ___ ____ _/ __/_____________ _/ /__ / / / _ \/ __ `/ /_/ ___/ ___/ __ `/ / _ \ / /___/ __/ /_/ / __(__ ) /__/ /_/ / / __/ /_____/\___/\__,_/_/ /____/\___/\__,_/_/\___/ (C)opyright 2026, Leafscale, LLC - https://www.leafscale.com Project: repoman Filename: tests/test_sync_args.reef Authors: Chris Tusa License: Description: Tests: sync argv parsing ******************************************************************************/ import sync import test.framework proc main() let runner = new framework.TestRunner() // Basic: no flags let a1: [string] = sync.build_rsync_args("/src/", "/dst/", false, false, false, new [string](0)) runner.assert_eq_bool(contains_str(a1, "-aHAX"), true, "has -aHAX") runner.assert_eq_bool(contains_str(a1, "--info=stats2"), true, "has --info=stats2") runner.assert_eq_bool(contains_str(a1, "--delete"), true, "delete on by default") runner.assert_eq_bool(contains_str(a1, "--exclude=node_modules/"), true, "node_modules excluded") runner.assert_eq_bool(contains_str(a1, "--exclude=.cache/"), true, ".cache excluded") runner.assert_eq_bool(last_two(a1, "/src/", "/dst/"), true, "src and dst end positional") // Dry run: --dry-run + --itemize-changes + --info=stats2 (NOT progress2) let a2: [string] = sync.build_rsync_args("/src/", "/dst/", true, false, true, new [string](0)) runner.assert_eq_bool(contains_str(a2, "--dry-run"), true, "dry-run flag") runner.assert_eq_bool(contains_str(a2, "--itemize-changes"), true, "itemize-changes flag") runner.assert_eq_bool(contains_str(a2, "--info=stats2"), true, "info stats2") runner.assert_eq_bool(contains_str(a2, "--info=stats2,progress2"), false, "no progress in dry-run") // No delete let a3: [string] = sync.build_rsync_args("/src/", "/dst/", false, true, false, new [string](0)) runner.assert_eq_bool(contains_str(a3, "--delete"), false, "no --delete with no_delete") // TTY interactive: stats2,progress2 let a4: [string] = sync.build_rsync_args("/src/", "/dst/", false, false, true, new [string](0)) runner.assert_eq_bool(contains_str(a4, "--info=stats2,progress2"), true, "tty progress") // Excluded repos in whole-tree mode let a5: [string] = sync.build_rsync_args("/src/", "/dst/", false, false, false, ["repo-A", "repo-B"]) runner.assert_eq_bool(contains_str(a5, "--exclude=repo-A/"), true, "excluded repo A") runner.assert_eq_bool(contains_str(a5, "--exclude=repo-B/"), true, "excluded repo B") runner.report() end main fn contains_str(arr: [string], target: string): bool let n: int = arr.length() mut i: int = 0 while i < n if arr[i] == target return true end if i = i + 1 end while return false end contains_str fn last_two(arr: [string], a: string, b: string): bool let n: int = arr.length() if n < 2 return false end if return arr[n - 2] == a and arr[n - 1] == b end last_two