Merge pull request #1455 from ajyoon/fix-flaky-db-tests

Support plain `cargo test` and disable unused doctests for speed
pull/1465/head
Nutomic 2021-02-25 22:54:40 +00:00 committed by GitHub
commit 82d97cf6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 94 additions and 2 deletions

View File

@ -29,7 +29,6 @@ steps:
environment: environment:
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
RUST_TEST_THREADS: 1
commands: commands:
- sudo apt-get update - sudo apt-get update
- sudo apt-get -y install --no-install-recommends espeak postgresql-client - sudo apt-get -y install --no-install-recommends espeak postgresql-client
@ -107,7 +106,6 @@ steps:
environment: environment:
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
RUST_TEST_THREADS: 1
commands: commands:
- apt-get update - apt-get update
- apt-get -y install --no-install-recommends espeak postgresql-client libssl-dev pkg-config libpq-dev - apt-get -y install --no-install-recommends espeak postgresql-client libssl-dev pkg-config libpq-dev

26
Cargo.lock generated
View File

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "activitystreams" name = "activitystreams"
version = "0.7.0-alpha.10" version = "0.7.0-alpha.10"
@ -1818,6 +1820,7 @@ dependencies = [
"regex", "regex",
"serde 1.0.123", "serde 1.0.123",
"serde_json", "serde_json",
"serial_test",
"sha2", "sha2",
"strum", "strum",
"strum_macros", "strum_macros",
@ -1845,6 +1848,7 @@ dependencies = [
"lemmy_db_schema", "lemmy_db_schema",
"log", "log",
"serde 1.0.123", "serde 1.0.123",
"serial_test",
"url", "url",
] ]
@ -3080,6 +3084,28 @@ dependencies = [
"serde 1.0.123", "serde 1.0.123",
] ]
[[package]]
name = "serial_test"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d"
dependencies = [
"lazy_static",
"parking_lot",
"serial_test_derive",
]
[[package]]
name = "serial_test_derive"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "sha-1" name = "sha-1"
version = "0.8.2" version = "0.8.2"

View File

@ -3,6 +3,9 @@ name = "lemmy_server"
version = "0.0.1" version = "0.0.1"
edition = "2018" edition = "2018"
[lib]
doctest = false
[profile.dev] [profile.dev]
debug = 0 debug = 0

View File

@ -7,6 +7,7 @@ edition = "2018"
[lib] [lib]
name = "lemmy_api" name = "lemmy_api"
path = "src/lib.rs" path = "src/lib.rs"
doctest = false
[dependencies] [dependencies]
lemmy_apub = { path = "../apub" } lemmy_apub = { path = "../apub" }

View File

@ -7,6 +7,7 @@ edition = "2018"
[lib] [lib]
name = "lemmy_apub" name = "lemmy_apub"
path = "src/lib.rs" path = "src/lib.rs"
doctest = false
[dependencies] [dependencies]
lemmy_utils = { path = "../utils" } lemmy_utils = { path = "../utils" }

View File

@ -6,6 +6,7 @@ edition = "2018"
[lib] [lib]
name = "lemmy_db_queries" name = "lemmy_db_queries"
path = "src/lib.rs" path = "src/lib.rs"
doctest = false
[dependencies] [dependencies]
lemmy_utils = { path = "../utils" } lemmy_utils = { path = "../utils" }
@ -23,3 +24,6 @@ url = { version = "2.2.0", features = ["serde"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
regex = "1.4.3" regex = "1.4.3"
bcrypt = "0.9.0" bcrypt = "0.9.0"
[dev-dependencies]
serial_test = "0.5.1"

View File

@ -37,8 +37,10 @@ mod tests {
post::{Post, PostForm}, post::{Post, PostForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -41,8 +41,10 @@ mod tests {
post::{Post, PostForm}, post::{Post, PostForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -41,8 +41,10 @@ mod tests {
post::{Post, PostForm, PostLike, PostLikeForm}, post::{Post, PostForm, PostLike, PostLikeForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -39,8 +39,10 @@ mod tests {
site::{Site, SiteForm}, site::{Site, SiteForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -37,8 +37,10 @@ mod tests {
post::{Post, PostForm, PostLike, PostLikeForm}, post::{Post, PostForm, PostLike, PostLikeForm},
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -9,6 +9,9 @@ extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate diesel_migrations; extern crate diesel_migrations;
#[cfg(test)]
extern crate serial_test;
use diesel::{result::Error, *}; use diesel::{result::Error, *};
use lemmy_db_schema::Url; use lemmy_db_schema::Url;
use regex::Regex; use regex::Regex;

View File

@ -133,8 +133,10 @@ mod tests {
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use serde_json::Value; use serde_json::Value;
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -212,8 +212,10 @@ mod tests {
post::*, post::*,
user::{UserForm, User_}, user::{UserForm, User_},
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -340,8 +340,10 @@ mod tests {
SortType, SortType,
}; };
use lemmy_db_schema::source::{community::*, user::*}; use lemmy_db_schema::source::{community::*, user::*};
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -199,9 +199,11 @@ impl Crud<ModAddForm> for ModAdd {
mod tests { mod tests {
use crate::{establish_unpooled_connection, Crud, ListingType, SortType}; use crate::{establish_unpooled_connection, Crud, ListingType, SortType};
use lemmy_db_schema::source::{comment::*, community::*, moderator::*, post::*, user::*}; use lemmy_db_schema::source::{comment::*, community::*, moderator::*, post::*, user::*};
use serial_test::serial;
// use Crud; // use Crud;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -80,8 +80,10 @@ mod tests {
SortType, SortType,
}; };
use lemmy_db_schema::source::{password_reset_request::PasswordResetRequest, user::*}; use lemmy_db_schema::source::{password_reset_request::PasswordResetRequest, user::*};
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -231,8 +231,10 @@ mod tests {
community::{Community, CommunityForm}, community::{Community, CommunityForm},
user::*, user::*,
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -147,8 +147,10 @@ mod tests {
SortType, SortType,
}; };
use lemmy_db_schema::source::{private_message::*, user::*}; use lemmy_db_schema::source::{private_message::*, user::*};
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -379,8 +379,10 @@ impl User for User_ {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{establish_unpooled_connection, source::user::*, ListingType, SortType}; use crate::{establish_unpooled_connection, source::user::*, ListingType, SortType};
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -81,8 +81,10 @@ mod tests {
user::*, user::*,
user_mention::*, user_mention::*,
}; };
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -3,6 +3,9 @@ name = "lemmy_db_schema"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
doctest = false
[dependencies] [dependencies]
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }

View File

@ -3,6 +3,9 @@ name = "lemmy_db_views"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
doctest = false
[dependencies] [dependencies]
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
@ -10,3 +13,6 @@ diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.123", features = ["derive"] }
log = "0.4.14" log = "0.4.14"
url = "2.2.0" url = "2.2.0"
[dev-dependencies]
serial_test = "0.5.1"

View File

@ -443,8 +443,10 @@ mod tests {
SortType, SortType,
}; };
use lemmy_db_schema::source::{comment::*, community::*, post::*, user::*}; use lemmy_db_schema::source::{comment::*, community::*, post::*, user::*};
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -1,3 +1,6 @@
#[cfg(test)]
extern crate serial_test;
pub mod comment_report_view; pub mod comment_report_view;
pub mod comment_view; pub mod comment_view;
pub mod post_report_view; pub mod post_report_view;

View File

@ -434,8 +434,10 @@ mod tests {
SortType, SortType,
}; };
use lemmy_db_schema::source::{community::*, post::*, user::*}; use lemmy_db_schema::source::{community::*, post::*, user::*};
use serial_test::serial;
#[test] #[test]
#[serial]
fn test_crud() { fn test_crud() {
let conn = establish_unpooled_connection(); let conn = establish_unpooled_connection();

View File

@ -3,6 +3,9 @@ name = "lemmy_db_views_actor"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
doctest = false
[dependencies] [dependencies]
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }

View File

@ -3,6 +3,9 @@ name = "lemmy_db_views_moderator"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
doctest = false
[dependencies] [dependencies]
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }

View File

@ -3,6 +3,9 @@ name = "lemmy_routes"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
doctest = false
[dependencies] [dependencies]
lemmy_utils = { path = "../utils" } lemmy_utils = { path = "../utils" }
lemmy_websocket = { path = "../websocket" } lemmy_websocket = { path = "../websocket" }

View File

@ -7,6 +7,7 @@ edition = "2018"
[lib] [lib]
name = "lemmy_structs" name = "lemmy_structs"
path = "src/lib.rs" path = "src/lib.rs"
doctest = false
[dependencies] [dependencies]
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }

View File

@ -6,6 +6,7 @@ edition = "2018"
[lib] [lib]
name = "lemmy_utils" name = "lemmy_utils"
path = "src/lib.rs" path = "src/lib.rs"
doctest = false
[dependencies] [dependencies]
regex = "1.4.3" regex = "1.4.3"

View File

@ -7,6 +7,7 @@ edition = "2018"
[lib] [lib]
name = "lemmy_websocket" name = "lemmy_websocket"
path = "src/lib.rs" path = "src/lib.rs"
doctest = false
[dependencies] [dependencies]
lemmy_utils = { path = "../utils" } lemmy_utils = { path = "../utils" }