aboutsummaryrefslogtreecommitdiff
path: root/alacritty_config_derive/tests/config.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2024-09-23 02:15:52 +0200
committerChristian Duerr <contact@christianduerr.com>2024-10-02 21:38:07 +0200
commit3db09595f31bd9f2f211d43d96f0acb887a68991 (patch)
tree43ecfa0cff7705516085a869c664d1972591d0a2 /alacritty_config_derive/tests/config.rs
parent51089cfeed1adfd741d8dcbe6c9cb9376f88a576 (diff)
downloadalacritty-3db09595f31bd9f2f211d43d96f0acb887a68991.tar.gz
alacritty-3db09595f31bd9f2f211d43d96f0acb887a68991.zip
Add migration support for TOML config changes
This patch allows running `alacritty migrate` to automatically apply configuration changes made to the TOML format, like moving `ipc_socket` to `general.ipc_socket`. This should reduce the friction of moving around individual options significantly, while also persisting the format of the existing TOML file thanks to `toml_edit`. The YAML migration has been simplified significantly to only switch the format of the file from YAML to TOML. The new TOML features are used for everything else.
Diffstat (limited to 'alacritty_config_derive/tests/config.rs')
-rw-r--r--alacritty_config_derive/tests/config.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/alacritty_config_derive/tests/config.rs b/alacritty_config_derive/tests/config.rs
index 27a968ed..be140cbe 100644
--- a/alacritty_config_derive/tests/config.rs
+++ b/alacritty_config_derive/tests/config.rs
@@ -1,4 +1,4 @@
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, Mutex, OnceLock};
use log::{Level, Log, Metadata, Record};
use serde::Deserialize;
@@ -83,10 +83,8 @@ struct NewType(usize);
#[test]
fn config_deserialize() {
- let logger = unsafe {
- LOGGER = Some(Logger::default());
- LOGGER.as_mut().unwrap()
- };
+ static LOGGER: OnceLock<Logger> = OnceLock::new();
+ let logger = LOGGER.get_or_init(Logger::default);
log::set_logger(logger).unwrap();
log::set_max_level(log::LevelFilter::Warn);
@@ -134,15 +132,16 @@ fn config_deserialize() {
]);
let warn_logs = logger.warn_logs.lock().unwrap();
assert_eq!(warn_logs.as_slice(), [
- "Config warning: field1 has been deprecated; use field2 instead",
- "Config warning: enom_error has been deprecated",
- "Config warning: gone has been removed; it's gone",
+ "Config warning: field1 has been deprecated; use field2 instead\nUse `alacritty migrate` \
+ to automatically resolve it",
+ "Config warning: enom_error has been deprecated\nUse `alacritty migrate` to automatically \
+ resolve it",
+ "Config warning: gone has been removed; it's gone\nUse `alacritty migrate` to \
+ automatically resolve it",
"Unused config key: field3",
]);
}
-static mut LOGGER: Option<Logger> = None;
-
/// Logger storing all messages for later validation.
#[derive(Default)]
struct Logger {