Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is tests/x.py maintained? And I tried fix it. #2754

Merged
merged 5 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ target/
# Shared-memory and WAL files created by SQLite.
*-shm
*-wal

# Integration testing extension library for SQLite.
ipaddr.dylib
ipaddr.so
7 changes: 6 additions & 1 deletion tests/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import time
from os import path
import shutil

# base dir of sqlx workspace
dir_workspace = path.dirname(path.dirname(path.realpath(__file__)))
Expand All @@ -13,8 +14,12 @@
# start database server and return a URL to use to connect
def start_database(driver, database, cwd):
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
return f"sqlite://{path.join(cwd, database)}"
return f"sqlite://{path.join(cwd, new_database)}"

res = subprocess.run(
["docker-compose", "up", "-d", driver],
Expand Down
2 changes: 1 addition & 1 deletion tests/sqlite/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sqlite.db
sqlite.test.db

3 changes: 1 addition & 2 deletions tests/sqlite/any.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sqlx::{Any, Sqlite};

Check warning on line 1 in tests/sqlite/any.rs

View workflow job for this annotation

GitHub Actions / SQLite (async-std)

unused import: `Sqlite`

Check warning on line 1 in tests/sqlite/any.rs

View workflow job for this annotation

GitHub Actions / SQLite (tokio)

unused import: `Sqlite`
use sqlx_test::new;

#[sqlx_macros::test]
Expand All @@ -6,8 +6,7 @@
sqlx::any::install_default_drivers();
let mut conn = new::<Any>().await?;

let res = sqlx::query("INSERT INTO accounts VALUES (?, ?, ?)")
.bind(87)
let res = sqlx::query("INSERT INTO accounts (name, is_active) VALUES (?, ?)")
.bind("Harrison Ford")
.bind(true)
.execute(&mut conn)
Expand Down
23 changes: 16 additions & 7 deletions tests/x.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ def run(command, comment=None, env=None, service=None, tag=None, args=None, data
environ["RUSTFLAGS"] += " --cfg sqlite_ipaddr"
else:
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:
database_url = start_database(service, database="sqlite/sqlite.db" if service == "sqlite" else "sqlx", cwd=dir_tests)
Expand Down Expand Up @@ -110,7 +116,7 @@ def run(command, comment=None, env=None, service=None, tag=None, args=None, data
*command.split(" "),
*command_args
],
env=dict(**os.environ, **environ),
env=dict(list(os.environ.items()) + list(environ.items())),
cwd=cwd,
)

Expand Down Expand Up @@ -201,12 +207,15 @@ def run(command, comment=None, env=None, service=None, tag=None, args=None, data
#

for version in ["8", "5_7"]:
run(
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}",
)
# Since docker mysql 5.7 using yaSSL(It only supports TLSv1.1), avoid running when using rustls.
# https://github.com/docker-library/mysql/issues/567
if not(version == "5_7" and tls == "rustls"):
run(
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
if tls != "none" and not(version == "5_7" and tls == "rustls"):
Expand Down
Loading