From ebead4fd33bcea13c77de85e7e568930fcdc1707 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 20 Nov 2026 06:27:38 -0500 Subject: [PATCH] test(worktrees): read generated git and jj listings back git's worktree list --porcelain -z and jj's workspace list template are parsed by hand, and one git example covered them. The new properties render generated listings and read them back through each provider's list with a scripted runner: - git: one to five worktrees whose paths and branch names hold spaces, newlines, non-ASCII text, "worktree " and "refs/heads/", detached worktrees, and locked and prunable lines. Each worktree comes back with its path, its leaf name (default for the main one), its eight-character revision, and its branch with refs/heads/ removed once. - jj: workspaces with spaces and non-ASCII names, with or without the default one, a blank and a malformed line. Each comes back in order with its change, default at the repository root and the others at the root jj reports for that name. Both packages gain qcheck and albedo_property as dev dependencies. The git example stays as a named regression. Planted: git fields split at a newline, refs/heads/ removed everywhere, blocks started only at the main worktree; jj names split at a space, the default workspace looked up. Each fails its property. --- extensions/git/gleam.toml | 2 + extensions/git/manifest.toml | 7 + extensions/git/test/albedo_ext_git_test.gleam | 132 +++++++++++++++++- extensions/jj/gleam.toml | 2 + extensions/jj/manifest.toml | 7 + extensions/jj/test/albedo_ext_jj_test.gleam | 78 ++++++++++- 6 files changed, 222 insertions(+), 6 deletions(-) diff --git a/extensions/git/gleam.toml b/extensions/git/gleam.toml index 211d8aea1..89d814bd9 100644 --- a/extensions/git/gleam.toml +++ b/extensions/git/gleam.toml @@ -13,3 +13,5 @@ albedo_sdk = { path = "../../packages/albedo_sdk" } [dev_dependencies] gleeunit = ">= 1.0.0 and < 2.0.0" +qcheck = ">= 1.0.5 and < 2.0.0" +albedo_property = { path = "../../packages/albedo_property" } diff --git a/extensions/git/manifest.toml b/extensions/git/manifest.toml index 64f599b9b..cb6c30428 100644 --- a/extensions/git/manifest.toml +++ b/extensions/git/manifest.toml @@ -20,6 +20,7 @@ packages = [ { name = "albedo_openai", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_bytes", "albedo_http", "albedo_json", "albedo_model", "albedo_model_stream", "albedo_sse", "gleam_json", "gleam_stdlib"], source = "local", path = "../../packages/albedo_openai" }, { name = "albedo_ports", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_clock", "albedo_protect", "gleam_erlang", "gleam_stdlib"], source = "local", path = "../../packages/albedo_ports" }, { name = "albedo_process", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_clock", "albedo_protect", "gleam_erlang", "gleam_otp", "gleam_stdlib"], source = "local", path = "../../packages/albedo_process" }, + { name = "albedo_property", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_env", "albedo_protect", "gleam_erlang", "gleam_stdlib", "qcheck"], source = "local", path = "../../packages/albedo_property" }, { name = "albedo_protect", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], source = "local", path = "../../packages/albedo_protect" }, { name = "albedo_sdk", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_bytes", "albedo_clock", "albedo_env", "albedo_file", "albedo_http", "albedo_image", "albedo_json", "albedo_model", "albedo_model_stream", "albedo_oauth", "albedo_openai", "albedo_ports", "albedo_process", "albedo_protect", "albedo_sqlite", "albedo_web", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_otp", "gleam_stdlib", "mist", "sqlight", "yamerl"], source = "local", path = "../../packages/albedo_sdk" }, { name = "albedo_sqlite", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_clock", "albedo_process", "esqlite", "gleam_erlang", "gleam_otp", "gleam_stdlib", "sqlight"], source = "local", path = "../../packages/albedo_sqlite" }, @@ -32,19 +33,25 @@ packages = [ { name = "gleam_http", version = "4.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "F065CE9941A7756ABBAEAE7F9F32A96CAD29DA3311A381DB2D926EA8E8C156DC" }, { name = "gleam_json", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "44FDAA8847BE8FC48CA7A1C089706BD54BADCC4C45B237A992EDDF9F2CDB2836" }, { name = "gleam_otp", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "DE4CA6850842F0266EE95317A25DD6A0A0F20CDFAB7C0ADC2E63251D7C3C72EC" }, + { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" }, { name = "gleam_stdlib", version = "1.0.5", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "CEE5B6C076A85B45F60C585F4316C63EC8B7127C119D5738C3958A9C4D50404E" }, + { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" }, { name = "gleeunit", version = "1.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "EC31ABA74256AEA531EDF8169931D775BBB384FED0A8A1BDC4DD9354E3E21826" }, { name = "glisten", version = "9.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging"], otp_app = "glisten", source = "hex", outer_checksum = "7795AA50830656F3A0316A6B26595F893C83272DA901B3405E31339CAA31A10B" }, { name = "gramps", version = "6.0.1", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "D55636072DEE173F6586A5679D3C02EC7A0DE3F8646B78C351B72908FF223DF7" }, { name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" }, { name = "logging", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "BC5F18CE5DD9686100229FE5409BDC3DD5C46D5A7DF2F804AD2D8F0DD6C5060E" }, { name = "mist", version = "6.0.3", build_tools = ["gleam"], requirements = ["exception", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten", "gramps", "hpack_erl", "logging"], source = "local", path = "../../vendor/mist" }, + { name = "prng", version = "6.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "prng", source = "hex", outer_checksum = "7FE3879E13150248BD370469205ED07B9404DD90670FEBB8CD0E7643707C420E" }, + { name = "qcheck", version = "1.0.5", build_tools = ["gleam"], requirements = ["exception", "gleam_regexp", "gleam_stdlib", "gleam_yielder", "prng"], otp_app = "qcheck", source = "hex", outer_checksum = "D27C12074776EC95F082EE56E0FC74685506B6EE26176F194D10F0322A39AC11" }, { name = "sqlight", version = "1.2.0", build_tools = ["gleam"], requirements = ["esqlite", "gleam_stdlib"], otp_app = "sqlight", source = "hex", outer_checksum = "841768D0A81107EE2DB46B949354F284A68B2E8098315C28A1FE3C07D206C17A" }, { name = "yamerl", version = "0.10.0", build_tools = ["rebar3"], requirements = [], otp_app = "yamerl", source = "hex", outer_checksum = "346ADB2963F1051DC837A2364E4ACF6EB7D80097C0F53CBDC3046EC8EC4B4E6E" }, ] [requirements] albedo_bytes = { path = "../../packages/albedo_bytes" } +albedo_property = { path = "../../packages/albedo_property" } albedo_sdk = { path = "../../packages/albedo_sdk" } gleam_stdlib = { version = ">= 1.0.0 and < 2.0.0" } gleeunit = { version = ">= 1.0.0 and < 2.0.0" } +qcheck = { version = ">= 1.0.5 and < 2.0.0" } diff --git a/extensions/git/test/albedo_ext_git_test.gleam b/extensions/git/test/albedo_ext_git_test.gleam index 2ce7d9e60..495fa8c63 100644 --- a/extensions/git/test/albedo_ext_git_test.gleam +++ b/extensions/git/test/albedo_ext_git_test.gleam @@ -1,15 +1,141 @@ +//// git's worktree listing read back from what `git worktree list +//// --porcelain -z` writes. The defects: a path split at a space, newline +//// or non-ASCII text, a block boundary lost so two worktrees merge, a +//// branch whose name holds `refs/heads/` cut again, a detached or bare +//// worktree given a branch, and the main worktree not named default. A +//// scripted runner stands in for git; the parser is all there is to test. + import albedo_ext_git/extension +import albedo_property import albedo_sdk/local_command import albedo_sdk/worktree -import gleam/option.{Some} +import gleam/list +import gleam/option.{type Option, None, Some} +import gleam/string import gleeunit +import qcheck.{type Generator} pub fn main() -> Nil { gleeunit.main() } +type Listed { + Listed( + path: String, + head: String, + branch: Option(String), + extra: List(String), + ) +} + +fn name() -> Generator(String) { + let piece = + qcheck.from_generators(qcheck.return("a"), [ + qcheck.return(" "), + qcheck.return("\n"), + qcheck.return("é"), + qcheck.return("worktree "), + qcheck.return("refs/heads/"), + qcheck.return("-"), + qcheck.return("x"), + ]) + use pieces <- qcheck.map(qcheck.generic_list(piece, qcheck.bounded_int(1, 4))) + "w" <> string.concat(pieces) +} + +fn listed() -> Generator(Listed) { + use leaf <- qcheck.bind(name()) + use head <- qcheck.bind( + qcheck.from_generators( + qcheck.return("0123456789abcdef0123456789abcdef01234567"), + [ + qcheck.return("fedcba9876543210fedcba9876543210fedcba98"), + ], + ), + ) + use branch <- qcheck.bind( + qcheck.from_generators(qcheck.return(None), [qcheck.map(name(), Some)]), + ) + use extra <- qcheck.map(qcheck.generic_list( + qcheck.from_generators(qcheck.return("locked"), [ + qcheck.return("locked in use"), + qcheck.return("prunable gitdir file points to non-existent location"), + ]), + qcheck.bounded_int(0, 2), + )) + Listed(string.replace(leaf, "/", "_"), head, branch, extra) +} + +fn listing() -> Generator(List(Listed)) { + use entries <- qcheck.map(qcheck.generic_list( + listed(), + qcheck.bounded_int(1, 5), + )) + // git lists the main worktree first; the others live elsewhere. + list.index_map(entries, fn(entry, index) { + case index { + 0 -> Listed(..entry, path: "/repo") + _ -> + Listed( + ..entry, + path: "/trees/" <> string.inspect(index) <> "/" <> entry.path, + ) + } + }) +} + +fn porcelain(entries: List(Listed)) -> String { + entries + |> list.map(fn(entry) { + let branch = case entry.branch { + Some(name) -> ["branch refs/heads/" <> name] + None -> ["detached"] + } + list.flatten([ + ["worktree " <> entry.path, "HEAD " <> entry.head], + branch, + entry.extra, + ]) + |> list.map(fn(field) { field <> "\u{0}" }) + |> string.concat + |> string.append("\u{0}") + }) + |> string.concat +} + +pub fn the_listing_reads_back_every_worktree_test() -> Nil { + use entries <- albedo_property.run(300, listing()) + let output = porcelain(entries) + let run = fn(command: local_command.Command) { + case command.args { + ["--no-optional-locks", "worktree", "list", "--porcelain", "-z"] -> + Ok(local_command.Exited(0, output)) + _ -> Error(Nil) + } + } + let assert Ok(found) = + extension.provider().list(run, worktree.Repo("git", "/repo", "/repo", "")) + assert list.length(found) == list.length(entries) + list.zip(entries, found) + |> list.index_map(fn(pair, index) { + let #(entry, read) = pair + assert read.path == Some(entry.path) + assert read.name + == case index { + 0 -> "default" + _ -> { + let assert Ok(leaf) = list.last(string.split(entry.path, "/")) + leaf + } + } + assert read.revision == Some(string.slice(entry.head, 0, 8)) + assert read.branch == entry.branch + }) + Nil +} + +/// The worked example: a branch whose own name holds `refs/heads/`. pub fn worktree_list_preserves_branch_name_test() -> Nil { - let provider = extension.provider() let run = fn(command: local_command.Command) { case command.args { ["--no-optional-locks", "worktree", "list", "--porcelain", "-z"] -> @@ -21,6 +147,6 @@ pub fn worktree_list_preserves_branch_name_test() -> Nil { } } let assert Ok([_, entry]) = - provider.list(run, worktree.Repo("git", "/repo", "/repo", "")) + extension.provider().list(run, worktree.Repo("git", "/repo", "/repo", "")) assert entry.branch == Some("topic/refs/heads/example") } diff --git a/extensions/jj/gleam.toml b/extensions/jj/gleam.toml index 30336e451..396f0a49a 100644 --- a/extensions/jj/gleam.toml +++ b/extensions/jj/gleam.toml @@ -12,3 +12,5 @@ albedo_sdk = { path = "../../packages/albedo_sdk" } [dev_dependencies] gleeunit = ">= 1.0.0 and < 2.0.0" +qcheck = ">= 1.0.5 and < 2.0.0" +albedo_property = { path = "../../packages/albedo_property" } diff --git a/extensions/jj/manifest.toml b/extensions/jj/manifest.toml index bc44416e0..f9da8ce73 100644 --- a/extensions/jj/manifest.toml +++ b/extensions/jj/manifest.toml @@ -20,6 +20,7 @@ packages = [ { name = "albedo_openai", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_bytes", "albedo_http", "albedo_json", "albedo_model", "albedo_model_stream", "albedo_sse", "gleam_json", "gleam_stdlib"], source = "local", path = "../../packages/albedo_openai" }, { name = "albedo_ports", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_clock", "albedo_protect", "gleam_erlang", "gleam_stdlib"], source = "local", path = "../../packages/albedo_ports" }, { name = "albedo_process", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_clock", "albedo_protect", "gleam_erlang", "gleam_otp", "gleam_stdlib"], source = "local", path = "../../packages/albedo_process" }, + { name = "albedo_property", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_env", "albedo_protect", "gleam_erlang", "gleam_stdlib", "qcheck"], source = "local", path = "../../packages/albedo_property" }, { name = "albedo_protect", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], source = "local", path = "../../packages/albedo_protect" }, { name = "albedo_sdk", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_bytes", "albedo_clock", "albedo_env", "albedo_file", "albedo_http", "albedo_image", "albedo_json", "albedo_model", "albedo_model_stream", "albedo_oauth", "albedo_openai", "albedo_ports", "albedo_process", "albedo_protect", "albedo_sqlite", "albedo_web", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_otp", "gleam_stdlib", "mist", "sqlight", "yamerl"], source = "local", path = "../../packages/albedo_sdk" }, { name = "albedo_sqlite", version = "0.1.0", build_tools = ["gleam"], requirements = ["albedo_clock", "albedo_process", "esqlite", "gleam_erlang", "gleam_otp", "gleam_stdlib", "sqlight"], source = "local", path = "../../packages/albedo_sqlite" }, @@ -32,18 +33,24 @@ packages = [ { name = "gleam_http", version = "4.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "F065CE9941A7756ABBAEAE7F9F32A96CAD29DA3311A381DB2D926EA8E8C156DC" }, { name = "gleam_json", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "44FDAA8847BE8FC48CA7A1C089706BD54BADCC4C45B237A992EDDF9F2CDB2836" }, { name = "gleam_otp", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "DE4CA6850842F0266EE95317A25DD6A0A0F20CDFAB7C0ADC2E63251D7C3C72EC" }, + { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" }, { name = "gleam_stdlib", version = "1.0.5", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "CEE5B6C076A85B45F60C585F4316C63EC8B7127C119D5738C3958A9C4D50404E" }, + { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" }, { name = "gleeunit", version = "1.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "EC31ABA74256AEA531EDF8169931D775BBB384FED0A8A1BDC4DD9354E3E21826" }, { name = "glisten", version = "9.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging"], otp_app = "glisten", source = "hex", outer_checksum = "7795AA50830656F3A0316A6B26595F893C83272DA901B3405E31339CAA31A10B" }, { name = "gramps", version = "6.0.1", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "D55636072DEE173F6586A5679D3C02EC7A0DE3F8646B78C351B72908FF223DF7" }, { name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" }, { name = "logging", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "BC5F18CE5DD9686100229FE5409BDC3DD5C46D5A7DF2F804AD2D8F0DD6C5060E" }, { name = "mist", version = "6.0.3", build_tools = ["gleam"], requirements = ["exception", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten", "gramps", "hpack_erl", "logging"], source = "local", path = "../../vendor/mist" }, + { name = "prng", version = "6.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "prng", source = "hex", outer_checksum = "7FE3879E13150248BD370469205ED07B9404DD90670FEBB8CD0E7643707C420E" }, + { name = "qcheck", version = "1.0.5", build_tools = ["gleam"], requirements = ["exception", "gleam_regexp", "gleam_stdlib", "gleam_yielder", "prng"], otp_app = "qcheck", source = "hex", outer_checksum = "D27C12074776EC95F082EE56E0FC74685506B6EE26176F194D10F0322A39AC11" }, { name = "sqlight", version = "1.2.0", build_tools = ["gleam"], requirements = ["esqlite", "gleam_stdlib"], otp_app = "sqlight", source = "hex", outer_checksum = "841768D0A81107EE2DB46B949354F284A68B2E8098315C28A1FE3C07D206C17A" }, { name = "yamerl", version = "0.10.0", build_tools = ["rebar3"], requirements = [], otp_app = "yamerl", source = "hex", outer_checksum = "346ADB2963F1051DC837A2364E4ACF6EB7D80097C0F53CBDC3046EC8EC4B4E6E" }, ] [requirements] +albedo_property = { path = "../../packages/albedo_property" } albedo_sdk = { path = "../../packages/albedo_sdk" } gleam_stdlib = { version = ">= 1.0.0 and < 2.0.0" } gleeunit = { version = ">= 1.0.0 and < 2.0.0" } +qcheck = { version = ">= 1.0.5 and < 2.0.0" } diff --git a/extensions/jj/test/albedo_ext_jj_test.gleam b/extensions/jj/test/albedo_ext_jj_test.gleam index 52bef696d..40c5a8c21 100644 --- a/extensions/jj/test/albedo_ext_jj_test.gleam +++ b/extensions/jj/test/albedo_ext_jj_test.gleam @@ -1,9 +1,81 @@ -//// Worktree detection needs a store with albedo's core tables, so its unit -//// test stays in albedo's `test/harness/worktree_vcs_test.gleam`, and the -//// worktrees end-to-end scenarios cover the extension through a daemon. +//// jj's workspace listing read back from what its `workspace list` +//// template writes. The defects: a workspace name split at a space or +//// non-ASCII text, a line without its change id taken for a workspace, +//// the default workspace looked up instead of placed at the repository +//// root, and another workspace's root taken from the wrong lookup. A +//// scripted runner stands in for jj; worktree detection against a real jj +//// repository is in the daemon's worktree_vcs_test. The worktrees +//// end-to-end scenarios cover the extension through a daemon. +import albedo_ext_jj/extension +import albedo_property +import albedo_sdk/local_command +import albedo_sdk/worktree +import gleam/list +import gleam/option.{None, Some} +import gleam/string import gleeunit +import qcheck.{type Generator} pub fn main() -> Nil { gleeunit.main() } + +fn name() -> Generator(String) { + let piece = + qcheck.from_generators(qcheck.return("a"), [ + qcheck.return(" "), + qcheck.return("é"), + qcheck.return("-"), + qcheck.return("default"), + qcheck.return("x"), + ]) + use pieces <- qcheck.map(qcheck.generic_list(piece, qcheck.bounded_int(1, 4))) + "w" <> string.concat(pieces) <> "z" +} + +/// Workspaces with distinct names, the default one first or not at all. +fn workspaces() -> Generator(List(#(String, String))) { + use names <- qcheck.bind(qcheck.generic_list(name(), qcheck.bounded_int(0, 5))) + use default <- qcheck.map(qcheck.bool()) + let names = list.unique(names) + let names = case default { + True -> ["default", ..names] + False -> names + } + list.index_map(names, fn(name, index) { + #(name, string.slice("kxyzmnop" <> string.inspect(index), 0, 8)) + }) +} + +pub fn the_listing_reads_back_every_workspace_test() -> Nil { + use listed <- albedo_property.run(300, workspaces()) + let output = + listed + |> list.map(fn(pair) { pair.0 <> "\t" <> pair.1 <> "\n" }) + |> string.concat + // A blank line and a line without a change are not workspaces. + |> string.append("\nstray\n") + let run = fn(command: local_command.Command) { + case command.args { + ["workspace", "list", ..] -> Ok(local_command.Exited(0, output)) + ["workspace", "root", "--name", name, ..] -> + Ok(local_command.Exited(0, "/trees/" <> name <> "\n")) + _ -> Error(Nil) + } + } + let assert Ok(found) = + extension.provider().list(run, worktree.Repo("jj", "/repo", "/repo", "")) + assert found + == list.map(listed, fn(pair) { + worktree.VcsEntry( + name: pair.0, + path: case pair.0 { + "default" -> Some("/repo") + other -> Some("/trees/" <> other) + }, + revision: Some(pair.1), + branch: None, + ) + }) +} -- knotmirror 0.0.1