Files
wehub-resource-sync 5357c39144
Fuzzer / Run Fuzzer (push) Has been cancelled
Race tests / Go race tests (ubuntu-22.04) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:01:40 +08:00

66 lines
1.6 KiB
Bash

#!/usr/bin/env bats
load $BATS_TEST_DIRNAME/helper/common.bash
load $BATS_TEST_DIRNAME/helper/query-server-common.bash
setup() {
skiponwindows "tests are flaky on Windows"
if [ "$SQL_ENGINE" = "remote-engine" ]; then
skip "This test tests remote connections directly, SQL_ENGINE is not needed."
fi
setup_common
TMPDIRS=$(pwd)/tmpdirs
mkdir -p $TMPDIRS/repo1
cd $TMPDIRS/repo1
dolt init
dolt sql <<SQL
create table ab (a int primary key, b varchar(100), key (b,a));
insert into ab
select * from (
with recursive cte(a,b) as (
select 0,'text_val'
union
select a+1, 'text_val' from cte where a < 1000
)
select * from cte
) dt;
SQL
}
teardown() {
stop_sql_server 1
teardown_common
rm -rf $TMPDIRS
cd $BATS_TMPDIR
}
@test "debug: debug produces expected files" {
run dolt debug -t 1 -o out -q "select count(*) from ab where b = 'text_val'"
[ "$status" -eq 0 ]
[[ "${lines[0]}" =~ "cpu" ]] || false
[[ "${lines[1]}" =~ "mem" ]] || false
[[ "${lines[2]}" =~ "trace" ]] || false
ls
tar -xvzf out.tar.gz
run ls out
[ "$status" -eq 0 ]
[[ "${lines[0]}" =~ "analysis.txt" ]] || false
[[ "${lines[1]}" =~ "cpu.pprof" ]] || false
[[ "${lines[2]}" =~ "exec.txt" ]] || false
[[ "${lines[3]}" =~ "input.sql" ]] || false
[[ "${lines[4]}" =~ "mem.pprof" ]] || false
[[ "${lines[5]}" =~ "plan.txt" ]] || false
[[ "${lines[6]}" =~ "trace.out" ]] || false
run cat out/plan.txt
[ "$status" -eq 0 ]
[[ "$output" =~ "IndexedTableAccess" ]] || false
}