sapling/eden/scm/tests/test-runlog.t
Muir Manders 1dcb7966fc tests: turn on eagerepo for a bunch of tests
Summary: These are the tests that passed after adding "$ eagerepo". I attempted to turn on eagerepo for all tests that didn't contain "$ eagerepo" or "configure modern".

Reviewed By: quark-zju

Differential Revision: D44445379

fbshipit-source-id: b283be6d5249f74e11a3205622961e457587e93b
2023-04-04 08:42:03 -07:00

347 lines
7.1 KiB
Raku

#chg-compatible
#require bash
$ eagerepo
$ enable progress
$ setconfig extensions.rustprogresstest="$TESTDIR/runlogtest.py" runlog.enable=True runlog.progress-refresh=0
$ waitforrunlog() {
> while ! cat .hg/runlog/*.json 2> /dev/null; do
> sleep 0.001
> done
> rm .hg/runlog/*
> # ignore windows race condition where runlogtest.py deletes file during touch
> touch $TESTTMP/go 2>/dev/null || true
> }
$ hg init repo && cd repo
Check basic command start/end.
$ hg basiccommandtest --waitfile=$TESTTMP/go 123 &
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"basiccommandtest",
"--waitfile=$TESTTMP/go",
"123"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": []
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"basiccommandtest",
"--waitfile=$TESTTMP/go",
"123"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": ".*", (re)
"exit_code": 123,
"progress": []
} (no-eol)
Make sure runlog works with progress disabled.
$ hg progresstest --waitfile=$TESTTMP/go --config progress.disable=True 2 &
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.disable=True",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": []
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.disable=True",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": [
{
"topic": "eating",
"unit": "apples",
"total": 2,
"position": 1
}
]
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.disable=True",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": [
{
"topic": "eating",
"unit": "apples",
"total": 2,
"position": 2
}
]
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.disable=True",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": ".*", (re)
"exit_code": 0,
"progress": []
} (no-eol)
Make sure runlog works with rust renderer.
$ rm $TESTTMP/go
$ hg progresstest --waitfile=$TESTTMP/go --config progress.renderer=rust:simple 2 &
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.renderer=rust:simple",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": []
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.renderer=rust:simple",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": [
{
"topic": "eating",
"unit": "apples",
"total": 2,
"position": 1
}
]
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.renderer=rust:simple",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": [
{
"topic": "eating",
"unit": "apples",
"total": 2,
"position": 2
}
]
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"progress.renderer=rust:simple",
"2"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": ".*", (re)
"exit_code": 0,
"progress": []
} (no-eol)
Make sure progress updates when runlog.progress-refresh set.
$ rm $TESTTMP/go
$ hg progresstest --waitfile=$TESTTMP/go --config runlog.progress-refresh=0.001 1 &
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"runlog.progress-refresh=0.001",
"1"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": []
} (no-eol)
$ waitforrunlog
{
"id": ".*", (re)
"command": [
"progresstest",
"--waitfile=$TESTTMP/go",
"--config",
"runlog.progress-refresh=0.001",
"1"
],
"pid": \d+, (re)
"download_bytes": 0,
"upload_bytes": 0,
"start_time": ".*", (re)
"end_time": null,
"exit_code": null,
"progress": [
{
"topic": "eating",
"unit": "apples",
"total": 1,
"position": 1
}
]
} (no-eol)
Wait for background process to exit.
$ waitforrunlog > /dev/null
Test we don't clean up entries with chance=0
$ setconfig runlog.cleanup-chance=0 runlog.cleanup-threshold=0
$ rm -f .hg/runlog/*
$ hg root > /dev/null
$ hg root > /dev/null
$ ls .hg/runlog/* | grep -v watchfile | wc -l | sed -e 's/ //g'
4
Test we always clean up with chance=1
$ setconfig runlog.cleanup-chance=1
$ hg root > /dev/null
$ ls .hg/runlog/* | grep -v watchfile | wc -l | sed -e 's/ //g'
2
Test runlog CLI command
Show completed entries (i.e. exited "root" entry)
$ setconfig runlog.cleanup-chance=0
$ rm -f .hg/runlog/*
$ hg root > /dev/null
$ hg debugrunlog --ended
Entry {
id: ".*", (re)
command: [
"root",
],
pid: \d+, (re)
download_bytes: 0,
upload_bytes: 0,
start_time: .*, (re)
end_time: Some(
.*, (re)
),
exit_code: Some(
0,
),
progress: [],
}
Show only running commands (i.e. "debugrunlog" command itself)
$ hg debugrunlog
Entry {
id: ".*", (re)
command: [
"debugrunlog",
],
pid: \d+, (re)
download_bytes: 0,
upload_bytes: 0,
start_time: .*, (re)
end_time: None,
exit_code: None,
progress: [],
}
Test we don't bail out if we can't write runlog.
$ rm -rf .hg/runlog
$ touch .hg/runlog
$ hg root
Error creating runlogger: * (glob)
$TESTTMP/repo