Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: enable rust_unit_test on windows (#1630)

Nathan.fooo17def1ffabcd
diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock
index eb0ea0d1b5..ac2c947912 100644
--- a/frontend/app_flowy/pubspec.lock
+++ b/frontend/app_flowy/pubspec.lock
@@ -966,7 +966,7 @@ packages:
name: reorderables
url: "https://pub.dartlang.org"
source: hosted
- version: "0.5.0"
+ version: "0.5.1"
rich_clipboard:
dependency: transitive
description:
diff --git a/frontend/app_flowy/pubspec.yaml b/frontend/app_flowy/pubspec.yaml
index d31fd86258..1f70a1fd8d 100644
--- a/frontend/app_flowy/pubspec.yaml
+++ b/frontend/app_flowy/pubspec.yaml
@@ -77,7 +77,7 @@ dependencies:
device_info_plus: ^3.2.1
fluttertoast: ^8.0.9
table_calendar: ^3.0.5
- reorderables: ^0.5.0
+ reorderables: ^0.5.1
linked_scroll_controller: ^0.2.0
hotkey_manager: ^0.1.7
fixnum: ^1.0.1
diff --git a/frontend/rust-lib/flowy-codegen/src/dart_event/dart_event.rs b/frontend/rust-lib/flowy-codegen/src/dart_event/dart_event.rs
index b06d76f943..1dc3a2f13f 100644
--- a/frontend/rust-lib/flowy-codegen/src/dart_event/dart_event.rs
+++ b/frontend/rust-lib/flowy-codegen/src/dart_event/dart_event.rs
@@ -22,7 +22,7 @@ pub fn gen(crate_name: &str) {
let crate_path = std::fs::canonicalize(".").unwrap().as_path().display().to_string();
let event_crates = parse_dart_event_files(vec![crate_path]);
- let event_ast = event_crates.iter().map(parse_event_crate).flatten().collect::<Vec<_>>();
+ let event_ast = event_crates.iter().flat_map(parse_event_crate).collect::<Vec<_>>();
let event_render_ctx = ast_to_event_render_ctx(event_ast.as_ref());
let mut render_result = DART_IMPORTED.to_owned();
@@ -109,14 +109,14 @@ pub fn parse_event_crate(event_crate: &DartEventCrate) -> Vec<EventASTContext> {
event_crate
.event_files
.iter()
- .map(|event_file| {
+ .flat_map(|event_file| {
let file_path = path_string_with_component(&event_crate.crate_path, vec![event_file.as_str()]);
let file_content = read_file(file_path.as_ref()).unwrap();
let ast = syn::parse_file(file_content.as_ref()).expect("Unable to parse file");
ast.items
.iter()
- .map(|item| match item {
+ .flat_map(|item| match item {
Item::Enum(item_enum) => {
let ast_result = ASTResult::new();
let attrs = flowy_ast::enum_from_ast(
@@ -135,10 +135,8 @@ pub fn parse_event_crate(event_crate: &DartEventCrate) -> Vec<EventASTContext> {
}
_ => vec![],
})
- .flatten()
.collect::<Vec<_>>()
})
- .flatten()
.collect::<Vec<EventASTContext>>()
}
diff --git a/frontend/rust-lib/flowy-codegen/src/protobuf_file/mod.rs b/frontend/rust-lib/flowy-codegen/src/protobuf_file/mod.rs
index 3a151292dd..5bb5367101 100644
--- a/frontend/rust-lib/flowy-codegen/src/protobuf_file/mod.rs
+++ b/frontend/rust-lib/flowy-codegen/src/protobuf_file/mod.rs
@@ -87,9 +87,9 @@ fn generate_rust_protobuf_files(
fn generate_dart_protobuf_files(
name: &str,
proto_file_output_path: &str,
- paths: &Vec<String>,
+ paths: &[String],
file_names: &Vec<String>,
- protoc_bin_path: &PathBuf,
+ protoc_bin_path: &Path,
) {
if std::env::var("CARGO_MAKE_WORKING_DIRECTORY").is_err() {
log::warn!("CARGO_MAKE_WORKING_DIRECTORY was not set, skip generate dart pb");
diff --git a/frontend/rust-lib/flowy-document/Cargo.toml b/frontend/rust-lib/flowy-document/Cargo.toml
index 572421d547..6c6162dc37 100644
--- a/frontend/rust-lib/flowy-document/Cargo.toml
+++ b/frontend/rust-lib/flowy-document/Cargo.toml
@@ -18,7 +18,7 @@ lib-dispatch = { path = "../lib-dispatch" }
flowy-database = { path = "../flowy-database" }
flowy-revision = { path = "../flowy-revision" }
flowy-error = { path = "../flowy-error", features = ["collaboration", "ot", "http_server", "serde", "db"] }
-dart-notify = { path = "../dart-notify", features = ["dart"] }
+dart-notify = { path = "../dart-notify" }
diesel = {version = "1.4.8", features = ["sqlite"]}
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
@@ -59,4 +59,4 @@ flowy-codegen = { path = "../flowy-codegen"}
sync = []
cloud_sync = ["sync"]
flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-revision/flowy_unit_test"]
-dart = ["flowy-codegen/dart"]
\ No newline at end of file
+dart = ["flowy-codegen/dart", "dart-notify/dart"]
\ No newline at end of file
diff --git a/frontend/rust-lib/flowy-folder/Cargo.toml b/frontend/rust-lib/flowy-folder/Cargo.toml
index 4c96dfd477..eb3405026c 100644
--- a/frontend/rust-lib/flowy-folder/Cargo.toml
+++ b/frontend/rust-lib/flowy-folder/Cargo.toml
@@ -16,7 +16,7 @@ lib-infra = { path = "../../../shared-lib/lib-infra" }
flowy-document = { path = "../flowy-document" }
flowy-database = { path = "../flowy-database" }
flowy-error = { path = "../flowy-error", features = ["db", "http_server"]}
-dart-notify = { path = "../dart-notify", features = ["dart"] }
+dart-notify = { path = "../dart-notify" }
lib-dispatch = { path = "../lib-dispatch" }
flowy-revision = { path = "../flowy-revision" }
@@ -50,4 +50,4 @@ default = []
sync = []
cloud_sync = ["sync"]
flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-revision/flowy_unit_test"]
-dart = ["flowy-codegen/dart"]
\ No newline at end of file
+dart = ["flowy-codegen/dart", "dart-notify/dart"]
\ No newline at end of file
diff --git a/frontend/rust-lib/flowy-grid/Cargo.toml b/frontend/rust-lib/flowy-grid/Cargo.toml
index ad13db46c8..ac8289f476 100644
--- a/frontend/rust-lib/flowy-grid/Cargo.toml
+++ b/frontend/rust-lib/flowy-grid/Cargo.toml
@@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
lib-dispatch = { path = "../lib-dispatch" }
-dart-notify = { path = "../dart-notify", features = ["dart"] }
+dart-notify = { path = "../dart-notify" }
flowy-revision = { path = "../flowy-revision" }
flowy-task= { path = "../flowy-task" }
flowy-error = { path = "../flowy-error", features = ["db"]}
@@ -56,5 +56,5 @@ flowy-codegen = { path = "../flowy-codegen"}
[features]
default = []
-dart = ["flowy-codegen/dart"]
+dart = ["flowy-codegen/dart", "dart-notify/dart"]
flowy_unit_test = ["flowy-revision/flowy_unit_test"]
\ No newline at end of file
diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs
index 2e69ed8a38..b624632e98 100644
--- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs
@@ -69,7 +69,7 @@ impl TypeOptionTransform for RichTextTypeOptionPB {
{
Some(stringify_cell_data(cell_str.to_owned(), decoded_field_type, decoded_field_type, field_rev).into())
} else {
- StrCellData::from_cell_str(&cell_str).ok()
+ StrCellData::from_cell_str(cell_str).ok()
}
}
}
diff --git a/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs b/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs
index f89740ed47..f085e4fc1e 100644
--- a/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs
+++ b/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs
@@ -206,7 +206,7 @@ async fn grid_switch_from_multi_select_to_text_test() {
let mut test = GridFieldTest::new().await;
let field_rev = test.get_first_field_rev(FieldType::MultiSelect).clone();
- let mut multi_select_type_option = test.get_multi_select_type_option(&field_rev.id);
+ let multi_select_type_option = test.get_multi_select_type_option(&field_rev.id);
let script_switch_field = vec![SwitchToField {
field_id: field_rev.id.clone(),
@@ -221,8 +221,8 @@ async fn grid_switch_from_multi_select_to_text_test() {
from_field_type: FieldType::MultiSelect,
expected_content: format!(
"{},{}",
- multi_select_type_option.get_mut(0).unwrap().name.to_string(),
- multi_select_type_option.get_mut(1).unwrap().name.to_string()
+ multi_select_type_option.get(0).unwrap().name,
+ multi_select_type_option.get(1).unwrap().name
),
}];
diff --git a/frontend/rust-lib/flowy-revision/src/rev_persistence.rs b/frontend/rust-lib/flowy-revision/src/rev_persistence.rs
index fa8bd5df07..f4be8bdbc3 100644
--- a/frontend/rust-lib/flowy-revision/src/rev_persistence.rs
+++ b/frontend/rust-lib/flowy-revision/src/rev_persistence.rs
@@ -364,7 +364,7 @@ impl<C> RevisionMemoryCacheDelegate for Arc<dyn RevisionDiskCache<C, Error = Flo
fn receive_ack(&self, object_id: &str, rev_id: i64) {
let changeset = RevisionChangeset {
object_id: object_id.to_string(),
- rev_id: rev_id.into(),
+ rev_id,
state: RevisionState::Ack,
};
match self.update_revision_record(vec![changeset]) {
diff --git a/frontend/rust-lib/flowy-user/Cargo.toml b/frontend/rust-lib/flowy-user/Cargo.toml
index 6e98f19df1..f6f51fa542 100644
--- a/frontend/rust-lib/flowy-user/Cargo.toml
+++ b/frontend/rust-lib/flowy-user/Cargo.toml
@@ -11,7 +11,7 @@ flowy-database = { path = "../flowy-database" }
flowy-error = { path = "../flowy-error", features = ["db", "http_server"] }
lib-infra = { path = "../../../shared-lib/lib-infra" }
-dart-notify = { path = "../dart-notify", features = ["dart"] }
+dart-notify = { path = "../dart-notify" }
lib-dispatch = { path = "../lib-dispatch" }
tracing = { version = "0.1", features = ["log"] }
@@ -45,7 +45,7 @@ rand_core = "0.6.3"
rand = "0.8.5"
[features]
-dart = ["flowy-codegen/dart"]
+dart = ["flowy-codegen/dart", "dart-notify/dart"]
[build-dependencies]
flowy-codegen = { path = "../flowy-codegen"}
diff --git a/frontend/rust-lib/flowy-user/src/services/database.rs b/frontend/rust-lib/flowy-user/src/services/database.rs
index 57ed6197c1..1ec25514f5 100644
--- a/frontend/rust-lib/flowy-user/src/services/database.rs
+++ b/frontend/rust-lib/flowy-user/src/services/database.rs
@@ -4,6 +4,7 @@ use flowy_database::{schema::user_table, DBConnection, Database};
use flowy_error::{ErrorCode, FlowyError};
use lazy_static::lazy_static;
use parking_lot::RwLock;
+use std::path::PathBuf;
use std::{collections::HashMap, sync::Arc, time::Duration};
pub struct UserDB {
@@ -34,7 +35,11 @@ impl UserDB {
Some(database) => return Ok(database.get_pool()),
}
- let dir = format!("{}/{}", self.db_dir, user_id);
+ let mut dir = PathBuf::new();
+ dir.push(&self.db_dir);
+ dir.push(user_id);
+ let dir = dir.to_str().unwrap().to_owned();
+
tracing::trace!("open user db {} at path: {}", user_id, dir);
let db = flowy_database::init(&dir).map_err(|e| {
log::error!("open user: {} db failed, {:?}", user_id, e);
diff --git a/frontend/scripts/makefile/tests.toml b/frontend/scripts/makefile/tests.toml
index 1cc730c20a..77449c2d79 100644
--- a/frontend/scripts/makefile/tests.toml
+++ b/frontend/scripts/makefile/tests.toml
@@ -1,21 +1,15 @@
-[tasks.dart_unit_test.macos]
-description = "Run flutter unit tests"
-script = '''
-cargo make --profile test-macos dart_unit_test_inner
-'''
-
-[tasks.dart_unit_test.linux]
-description = "Run flutter unit tests"
+[tasks.dart_unit_test]
script = '''
-cargo make --profile test-linux dart_unit_test_inner
+cargo make dart_unit_test_inner
'''
+script_runner = "@shell"
[tasks.dart_unit_test.windows]
-description = "Run flutter unit tests"
script = '''
cargo make --profile test-windows dart_unit_test_inner
'''
+script_runner = "@shell"
[tasks.dart_unit_test_inner]
dependencies = ["build-test-lib"]
@@ -32,14 +26,14 @@ run_task = { name = ["rust_lib_unit_test", "shared_lib_unit_test"] }
description = "Run rust-lib unit tests"
script = '''
cd rust-lib
-RUST_LOG=info cargo test --no-default-features --features="sync"
+cargo test --no-default-features --features="sync"
'''
[tasks.shared_lib_unit_test]
description = "Run shared-lib unit test"
script = '''
cd ../shared-lib
-RUST_LOG=info cargo test --no-default-features
+cargo test --no-default-features
'''
[tasks.check_grcov]