mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-11-17 05:48:08 +00:00
Is tests/x.py maintained? And I tried fix it. (#2754)
* chore:Added ipaddr extension library to gitignore * fix:In a Linux environment, shared libraries in the current directory are not loaded, so add the current directory to the LD_LIBRARY_PATH environment variable. * fix: Since confrict primary key when running multiple sqlite tests, removed specific primary key in insert. * chore: Since avoid git modified targeting, copy the db file to new test db file. * fix: Since docker mysql 5.7 using yaSSL(It only supports TLSv1.1), avoid running when using rustls.
This commit is contained in:
parent
080d57af3a
commit
00b077ab14
4
.gitignore
vendored
4
.gitignore
vendored
@ -13,3 +13,7 @@ target/
|
|||||||
# Shared-memory and WAL files created by SQLite.
|
# Shared-memory and WAL files created by SQLite.
|
||||||
*-shm
|
*-shm
|
||||||
*-wal
|
*-wal
|
||||||
|
|
||||||
|
# Integration testing extension library for SQLite.
|
||||||
|
ipaddr.dylib
|
||||||
|
ipaddr.so
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from os import path
|
from os import path
|
||||||
|
import shutil
|
||||||
|
|
||||||
# base dir of sqlx workspace
|
# base dir of sqlx workspace
|
||||||
dir_workspace = path.dirname(path.dirname(path.realpath(__file__)))
|
dir_workspace = path.dirname(path.dirname(path.realpath(__file__)))
|
||||||
@ -13,8 +14,12 @@ dir_tests = path.join(dir_workspace, "tests")
|
|||||||
# start database server and return a URL to use to connect
|
# start database server and return a URL to use to connect
|
||||||
def start_database(driver, database, cwd):
|
def start_database(driver, database, cwd):
|
||||||
if driver == "sqlite":
|
if driver == "sqlite":
|
||||||
|
database = path.join(cwd, database)
|
||||||
|
(base_path, ext) = path.splitext(database)
|
||||||
|
new_database = f"{base_path}.test{ext}"
|
||||||
|
shutil.copy(database, new_database)
|
||||||
# short-circuit for sqlite
|
# short-circuit for sqlite
|
||||||
return f"sqlite://{path.join(cwd, database)}"
|
return f"sqlite://{path.join(cwd, new_database)}"
|
||||||
|
|
||||||
res = subprocess.run(
|
res = subprocess.run(
|
||||||
["docker-compose", "up", "-d", driver],
|
["docker-compose", "up", "-d", driver],
|
||||||
|
|||||||
2
tests/sqlite/.gitignore
vendored
2
tests/sqlite/.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
sqlite.db
|
sqlite.test.db
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,7 @@ async fn it_encodes_bool_with_any() -> anyhow::Result<()> {
|
|||||||
sqlx::any::install_default_drivers();
|
sqlx::any::install_default_drivers();
|
||||||
let mut conn = new::<Any>().await?;
|
let mut conn = new::<Any>().await?;
|
||||||
|
|
||||||
let res = sqlx::query("INSERT INTO accounts VALUES (?, ?, ?)")
|
let res = sqlx::query("INSERT INTO accounts (name, is_active) VALUES (?, ?)")
|
||||||
.bind(87)
|
|
||||||
.bind("Harrison Ford")
|
.bind("Harrison Ford")
|
||||||
.bind(true)
|
.bind(true)
|
||||||
.execute(&mut conn)
|
.execute(&mut conn)
|
||||||
|
|||||||
23
tests/x.py
23
tests/x.py
@ -79,6 +79,12 @@ def run(command, comment=None, env=None, service=None, tag=None, args=None, data
|
|||||||
environ["RUSTFLAGS"] += " --cfg sqlite_ipaddr"
|
environ["RUSTFLAGS"] += " --cfg sqlite_ipaddr"
|
||||||
else:
|
else:
|
||||||
environ["RUSTFLAGS"] = "--cfg sqlite_ipaddr"
|
environ["RUSTFLAGS"] = "--cfg sqlite_ipaddr"
|
||||||
|
if platform.system() == "Linux":
|
||||||
|
if os.environ.get("LD_LIBRARY_PATH"):
|
||||||
|
environ["LD_LIBRARY_PATH"]= os.environ.get("LD_LIBRARY_PATH") + ":"+ os.getcwd()
|
||||||
|
else:
|
||||||
|
environ["LD_LIBRARY_PATH"]=os.getcwd()
|
||||||
|
|
||||||
|
|
||||||
if service is not None:
|
if service is not None:
|
||||||
database_url = start_database(service, database="sqlite/sqlite.db" if service == "sqlite" else "sqlx", cwd=dir_tests)
|
database_url = start_database(service, database="sqlite/sqlite.db" if service == "sqlite" else "sqlx", cwd=dir_tests)
|
||||||
@ -110,7 +116,7 @@ def run(command, comment=None, env=None, service=None, tag=None, args=None, data
|
|||||||
*command.split(" "),
|
*command.split(" "),
|
||||||
*command_args
|
*command_args
|
||||||
],
|
],
|
||||||
env=dict(**os.environ, **environ),
|
env=dict(list(os.environ.items()) + list(environ.items())),
|
||||||
cwd=cwd,
|
cwd=cwd,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -201,12 +207,15 @@ for runtime in ["async-std", "tokio"]:
|
|||||||
#
|
#
|
||||||
|
|
||||||
for version in ["8", "5_7"]:
|
for version in ["8", "5_7"]:
|
||||||
run(
|
# Since docker mysql 5.7 using yaSSL(It only supports TLSv1.1), avoid running when using rustls.
|
||||||
f"cargo test --no-default-features --features any,mysql,macros,_unstable-all-types,runtime-{runtime},tls-{tls}",
|
# https://github.com/docker-library/mysql/issues/567
|
||||||
comment=f"test mysql {version}",
|
if not(version == "5_7" and tls == "rustls"):
|
||||||
service=f"mysql_{version}",
|
run(
|
||||||
tag=f"mysql_{version}" if runtime == "async-std" else f"mysql_{version}_{runtime}",
|
f"cargo test --no-default-features --features any,mysql,macros,_unstable-all-types,runtime-{runtime},tls-{tls}",
|
||||||
)
|
comment=f"test mysql {version}",
|
||||||
|
service=f"mysql_{version}",
|
||||||
|
tag=f"mysql_{version}" if runtime == "async-std" else f"mysql_{version}_{runtime}",
|
||||||
|
)
|
||||||
|
|
||||||
## +client-ssl
|
## +client-ssl
|
||||||
if tls != "none" and not(version == "5_7" and tls == "rustls"):
|
if tls != "none" and not(version == "5_7" and tls == "rustls"):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user