From 7aaa6eab7560dda2d4b1ff1af5e67c982a577f7e Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Wed, 3 Jan 2024 16:24:12 -0800 Subject: [PATCH] Fix expect tests again, ansi colors are hard --- go/cmd/dolt/commands/sql.go | 7 ++++--- integration-tests/bats/sql-delimiter.expect | 14 +++++++------- integration-tests/bats/sql-unique-error.expect | 16 ++++++++-------- integration-tests/bats/sql-use.expect | 18 +++++++++--------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/go/cmd/dolt/commands/sql.go b/go/cmd/dolt/commands/sql.go index 0a7ae35733..9acd46b3ab 100644 --- a/go/cmd/dolt/commands/sql.go +++ b/go/cmd/dolt/commands/sql.go @@ -835,8 +835,9 @@ func formattedPrompts(db, branch string) (string, string) { return fmt.Sprintf("%s/%s> ", cyanDb, yellowBr), multi } -// getDBBranchFromSession returns the current database name for the session, handling all the errors along the way by printing -// red error messages to the CLI. If there was an issue getting the db name, the ok return value will be false. +// getDBBranchFromSession returns the current database name and current branch for the session, handling all the errors +// along the way by printing red error messages to the CLI. If there was an issue getting the db name, the ok return +// value will be false and the strings will be empty. func getDBBranchFromSession(sqlCtx *sql.Context, qryist cli.Queryist) (db string, branch string, ok bool) { _, resp, err := qryist.Query(sqlCtx, "select database() as db, active_branch() as branch") if err != nil { @@ -864,7 +865,7 @@ func getDBBranchFromSession(sqlCtx *sql.Context, qryist cli.Queryist) (db string } else { db = row[0].(string) - // It is possilbe to `use mydb/branch`, and as far as your session is concerned your database is mydb/branch. We + // It is possible to `use mydb/branch`, and as far as your session is concerned your database is mydb/branch. We // allow that, but also want to show the user the branch name in the prompt. So we munge the DB in this case. if strings.HasSuffix(db, "/"+branch) { db = db[:len(db)-len(branch)-1] diff --git a/integration-tests/bats/sql-delimiter.expect b/integration-tests/bats/sql-delimiter.expect index 7a8bd5aecb..563f8d2a62 100755 --- a/integration-tests/bats/sql-delimiter.expect +++ b/integration-tests/bats/sql-delimiter.expect @@ -3,32 +3,32 @@ set timeout 2 spawn dolt sql expect { - "doltsql/main> " { send "CREATE TABLE test(pk BIGINT PRIMARY KEY, v1 BIGINT);\r"; } + "> " { send "CREATE TABLE test(pk BIGINT PRIMARY KEY, v1 BIGINT);\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "INSERT INTO test VALUES (0,0);\r"; } + "> " { send "INSERT INTO test VALUES (0,0);\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "DELIMITER $$\r"; } + "> " { send "DELIMITER $$\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "INSERT INTO test VALUES (1,1)$$\r"; } + "> " { send "INSERT INTO test VALUES (1,1)$$\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "delimiter #\r"; } + "> " { send "delimiter #\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "CREATE TRIGGER tt BEFORE INSERT ON test FOR EACH ROW\r"; } + "> " { send "CREATE TRIGGER tt BEFORE INSERT ON test FOR EACH ROW\r"; } timeout { exit 1; } failed { exit 1; } } @@ -53,7 +53,7 @@ expect { failed { exit 1; } } expect { - "doltsql/main> " { send "DeLiMiTeR ;\r"; } + "> " { send "DeLiMiTeR ;\r"; } timeout { exit 1; } failed { exit 1; } } diff --git a/integration-tests/bats/sql-unique-error.expect b/integration-tests/bats/sql-unique-error.expect index 41b3603f50..645115f6f0 100755 --- a/integration-tests/bats/sql-unique-error.expect +++ b/integration-tests/bats/sql-unique-error.expect @@ -4,34 +4,34 @@ set timeout 2 spawn dolt sql expect { - "doltsql/main> " { send "CREATE TABLE test(pk BIGINT PRIMARY KEY, v1 BIGINT UNIQUE);\r"; } + "> " { send "CREATE TABLE test(pk BIGINT PRIMARY KEY, v1 BIGINT UNIQUE);\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "INSERT INTO test VALUES (0,0);\r"; } + "> " { send "INSERT INTO test VALUES (0,0);\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "INSERT INTO test VALUES (1,0);\r"; } + "> " { send "INSERT INTO test VALUES (1,0);\r"; } timeout { exit 1; } "UNIQUE" { exp_continue; } failed { exp_continue; } } expect { - "doltsql/main> " { send "INSERT INTO test VALUES (1,1);\r"; } + "> " { send "INSERT INTO test VALUES (1,1);\r"; } timeout { exit 1; } failed { exit 1; } } expect { - "doltsql/main> " { send "INSERT INTO test VALUES (2,2);\r"; } - timeout { exit 1; } - failed { exit 1; } -} + "> " { send "INSERT INTO test VALUES (2,2);\r"; } + timeout { exit 1; } + failed { exit 1; } + } expect eof diff --git a/integration-tests/bats/sql-use.expect b/integration-tests/bats/sql-use.expect index 354da9f3cd..d12502730e 100644 --- a/integration-tests/bats/sql-use.expect +++ b/integration-tests/bats/sql-use.expect @@ -7,32 +7,32 @@ spawn dolt sql # error output includes the line of the failed test expectation expect { - "*doltsql/main> " { send -- "use `doltsql/test`;\r"; } + -re ".*doltsql.*/.*main.*> " { send -- "use `doltsql/test`;\r"; } timeout { puts "$TESTFAILURE"; } } expect { - "*doltsql/test> " { send -- "show tables;\r"; } + -re ".*doltsql.*/.*test.*> " { send -- "show tables;\r"; } timeout { puts "$TESTFAILURE"; } } expect { - "*doltsql/test> " { send -- "use information_schema;\r"; } + -re ".*doltsql.*/.*test.*> " { send -- "use information_schema;\r"; } timeout { puts "$TESTFAILURE"; } } expect { - "*information_schema> " { send -- "show tables;\r"; } + -re ".*information_schema.*> " { send -- "show tables;\r"; } timeout { puts "$TESTFAILURE"; } } expect { - "*information_schema> " { send -- "CREATE DATABASE mydb;\r"; } + -re ".*information_schema.*> " { send -- "CREATE DATABASE mydb;\r"; } timeout { puts "$TESTFAILURE"; } } expect { - "*information_schema> " { send -- "use db1;\r"; } + -re ".*information_schema.*> " { send -- "use db1;\r"; } timeout { puts "$TESTFAILURE"; } } @@ -42,12 +42,12 @@ expect { } expect { - "*db1/main>" { send -- "use db2;\r"; } + -re ".*db1.*/.*main.*>" { send -- "use db2;\r"; } timeout { puts "$TESTFAILURE"; } } expect { - "*db2/main> " { send -- "select database();\r"; } + -re ".*db2.*/.*main.*> " { send -- "select database();\r"; } timeout { puts "$TESTFAILURE"; } } @@ -57,6 +57,6 @@ expect { } expect { - "mydb/main> " { send -- "exit ;\r"; } + -re ".*mydb.*/.*main.*> " { send -- "exit ;\r"; } timeout { puts "$TESTFAILURE"; } }