Throwaway prototypes for Sausage v3. Plan and decisions: ~/research/sausage-v3/PLAN.md. Results and evidence: the spike READMEs.
57 lines
2.3 KiB
Nu
57 lines
2.3 KiB
Nu
#!/usr/bin/env nu
|
|
# Probe each WASI operation separately. Native Git creates only the test fixtures.
|
|
def main [binary: path, stubs: path] {
|
|
let binary = ($binary | path expand)
|
|
let preloads = (glob ($stubs | path join '*.wasm') | each {|p| ['--preload' $'($p | path parse | get stem)=($p)'] } | flatten)
|
|
let root = (^mktemp -d /tmp/s3-git/probe.XXXXXX | str trim)
|
|
let repo = ($root | path join repo)
|
|
mkdir $repo
|
|
$env.GIT_CONFIG_NOSYSTEM = '1'
|
|
$env.GIT_AUTHOR_NAME = 'Spike'
|
|
$env.GIT_AUTHOR_EMAIL = 'spike@example.invalid'
|
|
$env.GIT_COMMITTER_NAME = 'Spike'
|
|
$env.GIT_COMMITTER_EMAIL = 'spike@example.invalid'
|
|
def --wrapped native [...args: string] { ^git -C $repo -c commit.gpgsign=false ...$args }
|
|
def probe [label: string, args: list<string>] {
|
|
let r = (^wasmtime run ...$preloads --dir /tmp/s3-git/dev::/dev --dir $'($root)::/repo' --env GIT_PAGER=cat --env GIT_EDITOR=true --env GIT_AUTHOR_NAME=Spike --env GIT_AUTHOR_EMAIL=spike@example.invalid --env GIT_COMMITTER_NAME=Spike --env GIT_COMMITTER_EMAIL=spike@example.invalid --env GIT_CONFIG_NOSYSTEM=1 --env HOME=/repo -- $binary -C /repo/repo -c core.pager=cat -c maintenance.auto=false ...$args | complete)
|
|
print $'=== ($label): exit ($r.exit_code) ==='
|
|
print $r.stdout
|
|
print --stderr $r.stderr
|
|
}
|
|
probe version ['--version']
|
|
probe init ['init' '-b' 'main']
|
|
native init -b main
|
|
'base' | save ($repo | path join base)
|
|
probe add ['add' 'base']
|
|
native add base
|
|
probe commit ['commit' '-m' 'base']
|
|
native commit -m base
|
|
probe status ['status' '--short']
|
|
probe log ['log' '--oneline']
|
|
probe branch ['branch' 'wasi-branch']
|
|
native branch feature
|
|
probe switch ['switch' 'feature']
|
|
'changed' | save --force ($repo | path join base)
|
|
probe diff ['diff']
|
|
native reset --hard
|
|
native switch feature
|
|
'feature' | save ($repo | path join feature)
|
|
native add feature
|
|
native commit -m feature
|
|
native switch main
|
|
probe fast-forward ['merge' '--ff-only' 'feature']
|
|
native merge --ff-only feature
|
|
native branch side
|
|
'main' | save ($repo | path join main)
|
|
native add main
|
|
native commit -m main
|
|
native switch side
|
|
'side' | save ($repo | path join side)
|
|
native add side
|
|
native commit -m side
|
|
native switch main
|
|
probe three-way ['merge' '--no-edit' 'side']
|
|
probe worktree ['worktree' 'add' '-b' 'linked' '/repo/linked']
|
|
print $'Fixtures: ($root)'
|
|
}
|