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

feat: auto set remote url based on locale #141

Merged
merged 2 commits into from
Dec 17, 2023
Merged

feat: auto set remote url based on locale #141

merged 2 commits into from
Dec 17, 2023

Conversation

wangl-cc
Copy link
Member

@wangl-cc wangl-cc commented Dec 15, 2023

我只在 macOS 测过,不知道 Windows 和 Linux 的简体中文 locale 是什么样的。理论上 zh-CN,zh-Hans 和 zh-Hans-CN 是所有简体中文可能的 locale 了。

Closes #138.

Copy link

codecov bot commented Dec 15, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (a9ed472) 53.05% compared to head (6af5e95) 53.09%.
Report is 1 commits behind head on main.

Files Patch % Lines
maa-cli/src/config/cli/resource.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
+ Coverage   53.05%   53.09%   +0.04%     
==========================================
  Files          33       33              
  Lines        2179     2183       +4     
==========================================
+ Hits         1156     1159       +3     
- Misses       1023     1024       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Cryolitia
Copy link
Member

Cryolitia commented Dec 17, 2023

LGTM

我这边Nix跑test会炸掉,所以只能关着test编译,不过看上去新加的这两个测试都过了

如果热更新部分能够打印更多日志就好了,比如在debug打印当前的locale,在default打印选择的url之类的

maa-cli> running 104 tests
maa-cli> test config::asst::tests::connection_config::default ... ok
maa-cli> test config::asst::tests::connection_config::set_address ... ok
maa-cli> test config::asst::tests::connection_config::connect_args ... ok
maa-cli> test config::asst::tests::instance_options ... ok
maa-cli> test config::asst::tests::resource_config::base_dirs ... ok
maa-cli> test config::asst::tests::resource_config::default ... ok
maa-cli> test config::asst::tests::resource_config::use_platform_diff_resource ... ok
maa-cli> test config::asst::tests::resource_config::use_user_resource ... FAILED
maa-cli> test config::asst::tests::resource_config::use_global_resource ... ok
maa-cli> test config::asst::tests::resource_config::test_push_resource ... ok
maa-cli> test config::asst::tests::serde::connection_config ... ok
maa-cli> test config::asst::tests::serde::deserialize_example ... FAILED
maa-cli> test config::asst::tests::serde::instance_options ... ok
maa-cli> test config::asst::tests::serde::asst_config ... ok
maa-cli> test config::asst::tests::serde::static_options ... ok
maa-cli> test config::cli::resource::tests::branch ... ok
maa-cli> test config::asst::tests::serde::resource_config ... FAILED
maa-cli> test config::cli::resource::tests::default ... ok
maa-cli> test config::cli::resource::tests::serde::backend ... ok
maa-cli> test config::cli::resource::tests::serde::config ... ok
maa-cli> test config::cli::resource::tests::serde::remote ... ok
maa-cli> test config::cli::resource::tests::ssh_key ... ok
maa-cli> test config::cli::resource::tests::test_check_zh_cn ... ok
maa-cli> test config::cli::resource::tests::url ... ok
maa-cli> test config::cli::tests::deserialize_channel ... ok
maa-cli> test config::cli::tests::deserialize_installer_config ... ok
maa-cli> test config::cli::tests::normalize_url_test ... ok
maa-cli> test config::cli::tests::get_resource_config ... ok
maa-cli> test config::asst::tests::resource_config::resource_dir ... ok
maa-cli> test config::task::client_type::tests::client_to_app ... ok
maa-cli> test config::task::client_type::tests::client_to_resource ... ok
maa-cli> test config::task::client_type::tests::client_to_string ... ok
maa-cli> test config::task::client_type::tests::deserialize ... ok
maa-cli> test config::task::client_type::tests::parse ... ok
maa-cli> test config::task::condition::tests::active::always ... ok
maa-cli> test config::task::condition::tests::active::combined ... ok
maa-cli> test config::task::condition::tests::active::time ... ok
maa-cli> test config::task::condition::tests::active::datetime ... ok
maa-cli> test config::task::condition::tests::active::weekday ... ok
maa-cli> test config::task::condition::tests::serde::time ... ok
maa-cli> test config::task::condition::tests::serde::datatime ... ok
maa-cli> test config::task::condition::tests::serde::weakday ... ok
maa-cli> test config::task::task_type::tests::as_str ... ok
maa-cli> test config::task::task_type::tests::to_cstring ... ok
maa-cli> test config::task::task_type::tests::deserialize ... ok
maa-cli> test config::task::tests::task::get_params ... ok
maa-cli> test config::task::tests::task::get_type ... ok
maa-cli> test config::task::tests::task::is_active ... ok
maa-cli> test config::task::tests::task_config::init ... ok
maa-cli> test config::task::value::input::tests::get::bool_input ... ok
maa-cli> test config::task::value::input::tests::get::input ... ok
maa-cli> test config::task::value::input::tests::get::select ... ok
maa-cli> test config::task::value::input::tests::serde::bool_input ... ok
maa-cli> test config::task::value::input::tests::serde::input ... ok
maa-cli> test config::task::value::input::tests::serde::select ... ok
maa-cli> test config::task::value::tests::get ... ok
maa-cli> test config::task::value::tests::get_panic - should panic ... ok
maa-cli> test config::task::value::tests::init ... ok
maa-cli> test config::task::value::tests::insert ... ok
maa-cli> test config::task::tests::task_config::serde::yaml ... ok
maa-cli> test config::task::value::tests::is_sth ... ok
maa-cli> test config::task::value::tests::insert_panic - should panic ... ok
maa-cli> test config::task::tests::task_config::serde::toml ... ok
maa-cli> test config::task::value::tests::merge ... ok
maa-cli> test config::task::value::tests::serde::bool ... ok
maa-cli> test config::task::value::tests::serde::float ... ok
maa-cli> test config::task::value::tests::serde::array ... ok
maa-cli> test config::task::value::tests::serde::int ... ok
maa-cli> test config::task::value::tests::serde::null ... ok
maa-cli> test config::task::value::tests::serde::input ... ok
maa-cli> test config::task::value::tests::serde::string ... ok
maa-cli> test config::task::value::tests::try_from ... ok
maa-cli> test config::task::value::tests::serde::value ... ok
maa-cli> test dirs::tests::get_dir::cache_relative ... ok
maa-cli> test dirs::tests::get_dir::config_relative ... ok
maa-cli> test dirs::tests::get_dir::state_relative ... ok
maa-cli> test dirs::tests::ensure ... ok
maa-cli> test dirs::tests::test_expand_tilde ... ok
maa-cli> test log::tests::log_level ... ok
maa-cli> test log::tests::logger ... ok
maa-cli> test config::tests::find_file ... ok
maa-cli> test run::copilot::tests::copilot_json::new ... ok
maa-cli> test run::copilot::tests::copilot_type::to_task ... ok
maa-cli> test dirs::tests::global_path_and_find ... ok
maa-cli> test run::copilot::tests::gen_operator_table ... ok
maa-cli> test run::fight::tests::test_fight ... ok
maa-cli> test run::playcover::tests::from ... ok
maa-cli> test run::copilot::tests::copilot_json::get_json_and_file ... ok
maa-cli> test run::roguelike::tests::test_roguelike ... ok
maa-cli> test run::roguelike::tests::theme_to_str ... ok
maa-cli> test run::tests::run::version ... ok
maa-cli> test run::copilot::tests::copilot_type::get_stage_name ... ok
maa-cli> test config::cli::tests::deserialize_example ... ok
maa-cli> test test::parser::complete ... ok
maa-cli> test config::task::tests::task_config::serde::json ... ok
maa-cli> test test::parser::list ... ok
maa-cli> test test::parser::copilot ... ok
maa-cli> test test::parser::rougelike ... ok
maa-cli> test dirs::tests::get_dir::data_relative ... ok
maa-cli> test test::parser::version ... ok
maa-cli> test test::parser::fight ... ok
maa-cli> test test::parser::dir ... ok
maa-cli> test test::parser::run ... ok
maa-cli> test test::parser::log_level ... ok
maa-cli> failures:
maa-cli> ---- config::asst::tests::resource_config::use_user_resource stdout ----
maa-cli> thread 'config::asst::tests::resource_config::use_user_resource' panicked at maa-cli/src/config/asst.rs:841:40:
maa-cli> called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
maa-cli> note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
maa-cli> ---- config::asst::tests::serde::deserialize_example stdout ----
maa-cli> thread 'config::asst::tests::serde::deserialize_example' panicked at maa-cli/src/config/asst.rs:475:65:
maa-cli> called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
maa-cli> ---- config::asst::tests::serde::resource_config stdout ----
maa-cli> 2023-12-17 06:30:50 Resource directory not found!
maa-cli> 2023-12-17 06:30:50 Hot update resource directory not found!
maa-cli> 2023-12-17 06:30:50 Resource directory not found!
maa-cli> 2023-12-17 06:30:50 Hot update resource directory not found!
maa-cli> 2023-12-17 06:30:50 Resource directory not found!
maa-cli> 2023-12-17 06:30:50 Hot update resource directory not found!
maa-cli> thread 'config::asst::tests::serde::resource_config' panicked at /build/maa-cli-0.4.0-beta.3-vendor.tar.gz/lazy_static/src/inline_lazy.rs:30:16:
maa-cli> Once instance has previously been poisoned
maa-cli> failures:
maa-cli>     config::asst::tests::resource_config::use_user_resource
maa-cli>     config::asst::tests::serde::deserialize_example
maa-cli>     config::asst::tests::serde::resource_config
maa-cli> test result: FAILED. 101 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
maa-cli> error: test failed, to rerun pass `-p maa-cli --bin maa`

@Cryolitia
Copy link
Member

虽然我不知道他在Linux设置为i18n.defaultLocale = "zh_CN.UTF-8";的时候获取到了什么,但是上游确实是设置到国内镜像了

@wangl-cc
Copy link
Member Author

失败的测试可能是 Nix 编译环境下不允许访问用户目录,设置成功了就行。

@wangl-cc wangl-cc merged commit e4c7e92 into main Dec 17, 2023
16 checks passed
@wangl-cc wangl-cc deleted the remote-url branch December 17, 2023 07:15
@Cryolitia
Copy link
Member

失败的测试可能是 Nix 编译环境下不允许访问用户目录,设置成功了就行。

Nix编译的时候不允许访问任何外部内容(必须保证软件包的一致性),我甚至不确定测试阶段能不能访问网络,可以加个PureBuild的feature(?

等maa-cli发一个正式版就可以上nixpkgs了

@wangl-cc
Copy link
Member Author

Nix 编译的时候必须要跑测试吗?有个和文件夹相关的测试需要访问临时文件夹和用户的配置文件夹。但是如果只是编译不跑测试,那就没问题了。

@Cryolitia
Copy link
Member

Cryolitia commented Dec 18, 2023

Nix 编译的时候必须要跑测试吗?有个和文件夹相关的测试需要访问临时文件夹和用户的配置文件夹。但是如果只是编译不跑测试,那就没问题了。

不跑也行吧,但是要去和reviewer解释你为什么把测试关了,到时候我就把这个PR的讨论扔过去(

@wangl-cc
Copy link
Member Author

wangl-cc commented Dec 18, 2023

哦哦,那可以把需要访问文件夹的测试标记成 ignore, 那样的话那些测试是默认不跑的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

对于大陆地区用户,可以将默认资源更新上游仓库设置为git.maa-org.net
2 participants