From 708bd9e3337f107410f977618dc47d6824191a16 Mon Sep 17 00:00:00 2001 From: Ross MacArthur Date: Mon, 10 Oct 2022 12:42:52 +0200 Subject: [PATCH] Apply templates per plugin not per file The template now uses a for loop to loop over the files in the plugin. the `each` field is no longer supported in the config file. --- README.md | 2 +- docs/src/Configuration.md | 2 +- docs/src/Examples.md | 2 +- src/config/edit.rs | 4 +- src/config/file.rs | 111 +----------------- src/config/mod.rs | 11 +- src/config/normalize.rs | 8 +- src/lock/file.rs | 4 +- src/lock/mod.rs | 32 ++--- src/lock/plugin.rs | 64 +--------- src/lock/script.rs | 94 ++++++--------- tests/lib.rs | 11 +- tests/testdata/clean/lock.stderr | 4 +- tests/testdata/clean/plugins.lock | 19 +-- tests/testdata/clean/source.stderr | 2 +- .../clean_permission_denied/lock.stderr | 4 +- .../clean_permission_denied/plugins.lock | 19 +-- .../clean_permission_denied/source.stderr | 2 +- tests/testdata/directories/lock.stderr | 4 +- tests/testdata/directories/plugins.lock | 19 +-- tests/testdata/directories/source.stderr | 2 +- .../directories_xdg_default/lock.stderr | 4 + .../directories_xdg_default/plugins.lock | 23 ++++ .../directories_xdg_default/plugins.toml | 5 + .../directories_xdg_default/source.stderr | 3 + .../directories_xdg_default/source.stdout | 2 + .../directories_xdg_from_env/lock.stderr | 4 + .../directories_xdg_from_env/plugins.lock | 23 ++++ .../directories_xdg_from_env/plugins.toml | 5 + .../directories_xdg_from_env/source.stderr | 3 + .../directories_xdg_from_env/source.stdout | 2 + tests/testdata/empty/lock.stderr | 4 +- tests/testdata/empty/plugins.lock | 19 +-- tests/testdata/empty/source.stderr | 2 +- .../testdata/github_bad_reinstall/lock.stderr | 2 +- .../github_bad_reinstall/plugins.lock | 19 +-- tests/testdata/github_bad_url/lock.stderr | 2 +- tests/testdata/github_bad_url/source.stderr | 2 +- tests/testdata/github_branch/lock.stderr | 4 +- tests/testdata/github_branch/plugins.lock | 19 +-- tests/testdata/github_branch/source.stderr | 2 +- tests/testdata/github_https/lock.stderr | 4 +- tests/testdata/github_https/plugins.lock | 19 +-- tests/testdata/github_https/source.stderr | 2 +- tests/testdata/github_submodule/lock.stderr | 4 +- tests/testdata/github_submodule/plugins.lock | 19 +-- tests/testdata/github_submodule/source.stderr | 2 +- tests/testdata/github_tag/lock.stderr | 4 +- tests/testdata/github_tag/plugins.lock | 19 +-- tests/testdata/github_tag/source.stderr | 2 +- tests/testdata/inline/lock.stderr | 4 +- tests/testdata/inline/plugins.lock | 21 +--- tests/testdata/inline/plugins.toml | 4 +- tests/testdata/inline/source.stderr | 2 +- tests/testdata/inline/source.stdout | 1 - .../testdata/override_config_file/lock.stderr | 4 +- .../override_config_file/plugins.lock | 19 +-- .../override_config_file/source.stderr | 2 +- tests/testdata/override_data_dir/lock.stderr | 2 +- tests/testdata/override_data_dir/plugins.lock | 19 +-- tests/testdata/profiles/lock.stderr | 4 +- tests/testdata/profiles/plugins.p1.lock | 21 +--- tests/testdata/profiles/plugins.toml | 8 +- tests/testdata/profiles/source.stderr | 2 +- tests/testdata/profiles/source.stdout | 1 - 65 files changed, 253 insertions(+), 505 deletions(-) create mode 100644 tests/testdata/directories_xdg_default/lock.stderr create mode 100644 tests/testdata/directories_xdg_default/plugins.lock create mode 100644 tests/testdata/directories_xdg_default/plugins.toml create mode 100644 tests/testdata/directories_xdg_default/source.stderr create mode 100644 tests/testdata/directories_xdg_default/source.stdout create mode 100644 tests/testdata/directories_xdg_from_env/lock.stderr create mode 100644 tests/testdata/directories_xdg_from_env/plugins.lock create mode 100644 tests/testdata/directories_xdg_from_env/plugins.toml create mode 100644 tests/testdata/directories_xdg_from_env/source.stderr create mode 100644 tests/testdata/directories_xdg_from_env/source.stdout diff --git a/README.md b/README.md index 8165a7ff..16850f01 100644 --- a/README.md +++ b/README.md @@ -627,7 +627,7 @@ following. ```toml [templates] -source = { value = 'source "{{ file }}"', each = true } +source = '{% for file in files %}source "{{ file }}"\n{% endfor %}' PATH = 'export PATH="{{ dir }}:$PATH"' path = 'path=( "{{ dir }}" $path )' fpath = 'fpath=( "{{ dir }}" $fpath )' diff --git a/docs/src/Configuration.md b/docs/src/Configuration.md index a289b109..d2b17900 100644 --- a/docs/src/Configuration.md +++ b/docs/src/Configuration.md @@ -236,7 +236,7 @@ following. ```toml [templates] -source = { value = 'source "{{ file }}"', each = true } +source = '{% for file in files %}source "{{ file }}"\n{% endfor %}' PATH = 'export PATH="{{ dir }}:$PATH"' path = 'path=( "{{ dir }}" $path )' fpath = 'fpath=( "{{ dir }}" $fpath )' diff --git a/docs/src/Examples.md b/docs/src/Examples.md index d310b2ad..a6118190 100644 --- a/docs/src/Examples.md +++ b/docs/src/Examples.md @@ -27,7 +27,7 @@ Then add a template that calls `zsh-defer source` instead of just `source`. ```toml [templates] -defer = { value = 'zsh-defer source "{{ file }}"', each = true } +defer = '{% for file in files %}zsh-defer source "{{ file }}"\n{% endfor %}' ``` Now any plugin that you want to defer you can apply the `defer` template. For diff --git a/src/config/edit.rs b/src/config/edit.rs index e1272dca..0128e975 100644 --- a/src/config/edit.rs +++ b/src/config/edit.rs @@ -230,7 +230,7 @@ tag = '0.1.0' apply = ["PATH", "source"] [templates] -prompt = { value = 'ln -sf "{{ file }}" "{{ data_dir }}/functions/prompt_{{ name }}_setup"', each = true } +prompt = '{% for file in files %}ln -sf "{{ file }}" "{{ data_dir }}/functions/prompt_{{ name }}_setup"{% endfor %}' # yes this is the pure plugin [plugins.pure] @@ -257,7 +257,7 @@ use = ["{{ name }}.zsh"] apply = ["PATH", "source"] [templates] -prompt = { value = 'ln -sf "{{ file }}" "{{ data_dir }}/functions/prompt_{{ name }}_setup"', each = true } +prompt = '{% for file in files %}ln -sf "{{ file }}" "{{ data_dir }}/functions/prompt_{{ name }}_setup"{% endfor %}' # yes this is the pure plugin [plugins.pure] diff --git a/src/config/file.rs b/src/config/file.rs index 451cd5a8..315b2187 100644 --- a/src/config/file.rs +++ b/src/config/file.rs @@ -14,7 +14,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use thiserror::Error; use url::Url; -use crate::config::{GitReference, Shell, Template}; +use crate::config::{GitReference, Shell}; /// The contents of the configuration file. #[derive(Debug, Default, Deserialize)] @@ -28,7 +28,7 @@ pub struct RawConfig { /// The default list of template names to apply to each matched file. pub apply: Option>, /// A map of name to template string. - pub templates: IndexMap, + pub templates: IndexMap, /// A map of name to plugin. pub plugins: IndexMap, /// Any extra keys, @@ -195,75 +195,6 @@ impl FromStr for Shell { } } -mod template { - use super::*; - - struct Visitor; - - /// The same as a [`Template`]. It is used to prevent recursion when - /// deserializing. - #[derive(Deserialize)] - struct TemplateAux { - value: String, - each: bool, - } - - impl From for Template { - fn from(aux: TemplateAux) -> Self { - let TemplateAux { value, each } = aux; - Self { value, each } - } - } - - impl From<&str> for Template { - fn from(s: &str) -> Self { - Self { - value: s.to_string(), - each: false, - } - } - } - - impl<'de> de::Visitor<'de> for Visitor { - type Value = Template; - - fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("string or map") - } - - fn visit_str(self, value: &str) -> result::Result - where - E: de::Error, - { - Ok(From::from(value)) - } - - fn visit_map(self, visitor: M) -> result::Result - where - M: de::MapAccess<'de>, - { - let aux: TemplateAux = - Deserialize::deserialize(de::value::MapAccessDeserializer::new(visitor))?; - Ok(aux.into()) - } - } - - /// Manually implement `Deserialize` for a `Template`. - /// - /// Unfortunately we can not use [the recommended method][string-or-struct], - /// because we are storing `Template`s in a map. - /// - /// [string-or-struct](https://serde.rs/string-or-struct.html) - impl<'de> Deserialize<'de> for Template { - fn deserialize(deserializer: D) -> result::Result - where - D: Deserializer<'de>, - { - deserializer.deserialize_any(Visitor) - } - } -} - /// Produced when we fail to parse a Git protocol. #[derive(Debug, Error)] #[error("expected one of `git`, `https`, or `ssh`, got `{}`", self.0)] @@ -438,44 +369,6 @@ mod tests { ) } - #[derive(Debug, Deserialize)] - struct TemplateTest { - t: Template, - } - - #[test] - fn template_deserialize_as_str() { - let test: TemplateTest = toml::from_str("t = 'test'").unwrap(); - assert_eq!( - test.t, - Template { - value: "test".to_string(), - each: false - } - ); - } - - #[test] - fn template_deserialize_as_map() { - let test: TemplateTest = toml::from_str("t = { value = 'test', each = true }").unwrap(); - assert_eq!( - test.t, - Template { - value: "test".to_string(), - each: true - } - ); - } - - #[test] - fn template_deserialize_invalid() { - let error = toml::from_str::("t = 0").unwrap_err(); - assert_eq!( - error.to_string(), - "invalid type: integer `0`, expected string or map for key `t` at line 1 column 5" - ); - } - #[derive(Debug, Deserialize)] struct TestGitReference { #[serde(flatten)] diff --git a/src/config/mod.rs b/src/config/mod.rs index e9220134..dcc793b8 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -30,7 +30,7 @@ pub struct Config { /// The default list of template names to apply to each matched file. pub apply: Option>, /// A map of name to template string. - pub templates: IndexMap, + pub templates: IndexMap, /// Each configured plugin. pub plugins: Vec, } @@ -42,15 +42,6 @@ pub enum Shell { Zsh, } -/// A wrapper around a template string. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -pub struct Template { - /// The actual template string. - pub value: String, - /// Whether this template should be applied to each file. - pub each: bool, -} - /// A configured plugin. #[derive(Debug, PartialEq, Eq)] pub enum Plugin { diff --git a/src/config/normalize.rs b/src/config/normalize.rs index e38eb086..d5a827a8 100644 --- a/src/config/normalize.rs +++ b/src/config/normalize.rs @@ -8,7 +8,7 @@ use indexmap::IndexMap; use url::Url; use crate::config::file::{GitProtocol, RawConfig, RawPlugin}; -use crate::config::{Config, ExternalPlugin, InlinePlugin, Plugin, Shell, Source, Template}; +use crate::config::{Config, ExternalPlugin, InlinePlugin, Plugin, Shell, Source}; use crate::util::TEMPLATE_ENGINE; /// The Gist domain host. @@ -35,7 +35,7 @@ pub fn normalize(raw_config: RawConfig, warnings: &mut Vec) -> Result, + templates: &IndexMap, warnings: &mut Vec, ) -> Result { enum TempSource { @@ -249,7 +249,7 @@ where fn validate_template_names( shell: Shell, apply: &Option>, - templates: &IndexMap, + templates: &IndexMap, ) -> Result<()> { if let Some(apply) = apply { for name in apply { diff --git a/src/lock/file.rs b/src/lock/file.rs index f2f73672..bf923ba7 100644 --- a/src/lock/file.rs +++ b/src/lock/file.rs @@ -7,7 +7,7 @@ use anyhow::{Context as ResultExt, Error, Result}; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; -use crate::config::{InlinePlugin, Template}; +use crate::config::InlinePlugin; use crate::context::Context; /// A locked `Config`. @@ -22,7 +22,7 @@ pub struct LockedConfig { /// /// Note: this field must come last in the struct for it to serialize /// properly. - pub templates: IndexMap, + pub templates: IndexMap, /// Any errors that occurred while generating this `LockedConfig`. #[serde(skip)] pub errors: Vec, diff --git a/src/lock/mod.rs b/src/lock/mod.rs index de3abcc2..070387c2 100644 --- a/src/lock/mod.rs +++ b/src/lock/mod.rs @@ -12,7 +12,7 @@ use itertools::{Either, Itertools}; use once_cell::sync::Lazy; use rayon::prelude::*; -use crate::config::{Config, MatchesProfile, Plugin, Shell, Template}; +use crate::config::{Config, MatchesProfile, Plugin, Shell}; use crate::context::Context; pub use crate::lock::file::LockedConfig; use crate::lock::file::{LockedExternalPlugin, LockedPlugin}; @@ -86,8 +86,9 @@ pub fn config(ctx: &Context, config: Config) -> Result { .push((index, plugin)); } - let matches = &matches.as_ref().unwrap_or_else(|| shell.default_matches()); - #[allow(clippy::redundant_closure)] + let matches = matches + .as_deref() + .unwrap_or_else(|| shell.default_matches()); let apply = apply.as_ref().unwrap_or_else(|| Shell::default_apply()); let count = map.len(); let mut errors = Vec::new(); @@ -117,9 +118,8 @@ pub fn config(ctx: &Context, config: Config) -> Result { let mut locked = Vec::with_capacity(plugins.len()); for (index, plugin) in plugins { let name = plugin.name.clone(); - let plugin = - plugin::lock(ctx, &templates, source.clone(), matches, apply, plugin) - .with_context(s!("failed to install plugin `{}`", name)); + let plugin = plugin::lock(ctx, source.clone(), matches, apply, plugin) + .with_context(s!("failed to install plugin `{}`", name)); locked.push((index, plugin)); } Ok(locked) @@ -171,7 +171,7 @@ pub fn config(ctx: &Context, config: Config) -> Result { impl Shell { /// The default files to match on for this shell. - fn default_matches(&self) -> &Vec { + fn default_matches(&self) -> &[String] { static DEFAULT_MATCHES_BASH: Lazy> = Lazy::new(|| { vec_into![ "{{ name }}.plugin.bash", @@ -203,19 +203,19 @@ impl Shell { } /// The default templates for this shell. - pub fn default_templates(&self) -> &IndexMap { - static DEFAULT_TEMPLATES_BASH: Lazy> = Lazy::new(|| { + pub fn default_templates(&self) -> &IndexMap { + static DEFAULT_TEMPLATES_BASH: Lazy> = Lazy::new(|| { indexmap_into! { "PATH" => "export PATH=\"{{ dir }}:$PATH\"", - "source" => Template::from("source \"{{ file }}\"").each(true) + "source" => "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" } }); - static DEFAULT_TEMPLATES_ZSH: Lazy> = Lazy::new(|| { + static DEFAULT_TEMPLATES_ZSH: Lazy> = Lazy::new(|| { indexmap_into! { "PATH" => "export PATH=\"{{ dir }}:$PATH\"", "path" => "path=( \"{{ dir }}\" $path )", "fpath" => "fpath=( \"{{ dir }}\" $fpath )", - "source" => Template::from("source \"{{ file }}\"").each(true) + "source" => "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" } }); match self { @@ -231,14 +231,6 @@ impl Shell { } } -impl Template { - /// Set whether this template should be applied to every file. - fn each(mut self, each: bool) -> Self { - self.each = each; - self - } -} - impl LockedConfig { /// Verify that the `LockedConfig` is okay. pub fn verify(&self, ctx: &Context) -> bool { diff --git a/src/lock/plugin.rs b/src/lock/plugin.rs index a7c7d5fc..ce7265f8 100644 --- a/src/lock/plugin.rs +++ b/src/lock/plugin.rs @@ -1,11 +1,10 @@ use std::path::{Path, PathBuf}; use anyhow::{bail, Context as ResultExt, Result}; -use indexmap::IndexMap; use maplit::hashmap; use serde::Serialize; -use crate::config::{ExternalPlugin, Source, Template}; +use crate::config::{ExternalPlugin, Source}; use crate::context::Context; use crate::lock::file::LockedExternalPlugin; use crate::lock::source::LockedSource; @@ -14,7 +13,6 @@ use crate::util::TEMPLATE_ENGINE; /// Consume the [`ExternalPlugin`] and convert it to a [`LockedExternalPlugin`]. pub fn lock( ctx: &Context, - templates: &IndexMap, locked_source: LockedSource, global_matches: &[String], global_apply: &[String], @@ -82,13 +80,6 @@ pub fn lock( break; } } - if files.is_empty() - && templates - .iter() - .any(|(key, value)| apply.contains(key) && value.each) - { - bail!("no files matched for `{}`", &name); - } } LockedExternalPlugin { @@ -150,7 +141,7 @@ mod tests { use url::Url; - use crate::config::{GitReference, Shell}; + use crate::config::GitReference; use crate::lock::source; #[test] @@ -172,15 +163,7 @@ mod tests { let locked_source = source::lock(&ctx, plugin.source.clone()).unwrap(); let clone_dir = dir.join("repos/github.com/rossmacarthur/sheldon-test"); - let locked = lock( - &ctx, - &Shell::default().default_templates().clone(), - locked_source, - &[], - &["hello".into()], - plugin, - ) - .unwrap(); + let locked = lock(&ctx, locked_source, &[], &["hello".into()], plugin).unwrap(); assert_eq!(locked.name, String::from("test")); assert_eq!(locked.dir(), clone_dir); @@ -215,7 +198,6 @@ mod tests { let locked = lock( &ctx, - &Shell::default().default_templates().clone(), locked_source, &["*.plugin.zsh".to_string()], &["hello".to_string()], @@ -229,35 +211,6 @@ mod tests { assert_eq!(locked.apply, vec![String::from("hello")]); } - #[test] - fn external_plugin_lock_git_with_matches_error() { - let temp = tempfile::tempdir().expect("create temporary directory"); - let dir = temp.path(); - let ctx = Context::testing(dir); - let plugin = ExternalPlugin { - name: "test".to_string(), - source: Source::Git { - url: Url::parse("https://github.com/rossmacarthur/sheldon-test").unwrap(), - reference: Some(GitReference::Tag("v0.1.0".to_string())), - }, - dir: None, - uses: None, - apply: None, - profiles: None, - }; - let locked_source = source::lock(&ctx, plugin.source.clone()).unwrap(); - - lock( - &ctx, - &Shell::default().default_templates().clone(), - locked_source, - &["*doesnotexist*".to_string()], - &["source".to_string()], - plugin, - ) - .unwrap_err(); - } - #[test] fn external_plugin_lock_git_with_matches_not_each() { let temp = tempfile::tempdir().expect("create temporary directory"); @@ -279,7 +232,6 @@ mod tests { let locked = lock( &ctx, - &Shell::default().default_templates().clone(), locked_source, &["*doesnotexist*".to_string()], &["PATH".to_string()], @@ -314,15 +266,7 @@ mod tests { let locked_source = source::lock(&ctx, plugin.source.clone()).unwrap(); let download_dir = dir.join("downloads/github.com/rossmacarthur/sheldon-test/raw/master"); - let locked = lock( - &ctx, - &Shell::default().default_templates().clone(), - locked_source, - &[], - &["hello".to_string()], - plugin, - ) - .unwrap(); + let locked = lock(&ctx, locked_source, &[], &["hello".to_string()], plugin).unwrap(); assert_eq!(locked.name, String::from("test")); assert_eq!(locked.dir(), download_dir); diff --git a/src/lock/script.rs b/src/lock/script.rs index b37b8222..a54125df 100644 --- a/src/lock/script.rs +++ b/src/lock/script.rs @@ -1,10 +1,17 @@ use anyhow::{Context as ResultExt, Result}; -use maplit::hashmap; +use serde::Serialize; use crate::context::Context; use crate::lock::file::LockedPlugin; use crate::lock::LockedConfig; +#[derive(Debug, Serialize)] +struct ExternalData<'a> { + name: &'a str, + dir: &'a str, + files: Vec<&'a str>, +} + impl LockedConfig { /// Generate the script. pub fn script(&self, ctx: &Context) -> Result { @@ -12,77 +19,54 @@ impl LockedConfig { let mut engine = upon::Engine::new(); for (name, template) in &self.templates { engine - .add_template(name, &template.value) + .add_template(name, template) .with_context(s!("failed to compile template `{}`", name))?; } - macro_rules! render { - ($name:expr, $data:expr) => { - &engine - .get_template($name) - .unwrap() - .render($data) - .with_context(s!("failed to render template `{}`", $name))? - }; - } - let mut script = String::new(); for plugin in &self.plugins { match plugin { LockedPlugin::External(plugin) => { - for name in &plugin.apply { - let dir_as_str = plugin + // Data to use in template rendering + let mut files = Vec::new(); + for f in &plugin.files { + files.push(f.to_str().context("plugin directory is not valid UTF-8")?); + } + let data = ExternalData { + name: &plugin.name, + dir: plugin .dir() .to_str() - .context("plugin directory is not valid UTF-8")?; - - // Data to use in template rendering - let mut data = hashmap! { - "data_dir" => self - .ctx - .data_dir() - .to_str() - .context("data directory is not valid UTF-8")?, - "name" => &plugin.name, - "dir" => dir_as_str, - }; + .context("plugin directory is not valid UTF-8")?, + files, + }; - if self.templates.get(name.as_str()).unwrap().each { - for file in &plugin.files { - let as_str = - file.to_str().context("plugin file is not valid UTF-8")?; - data.insert("file", as_str); - script.push_str(render!(name, &data)); - script.push('\n'); - } - } else { - script.push_str(render!(name, &data)); + for name in &plugin.apply { + let out = &engine + .get_template(name) + .unwrap() + .render(&data) + .with_context(s!("failed to render template `{}`", name))?; + script.push_str(out); + if !out.ends_with('\n') { script.push('\n'); } } status_v!(ctx, "Rendered", &plugin.name); } LockedPlugin::Inline(plugin) => { - let data = hashmap! { - "data_dir" => self - .ctx - .data_dir() - .to_str() - .context("data directory is not valid UTF-8")?, - "name" => &plugin.name, - }; - script.push_str( - &engine - .compile(&plugin.raw) - .with_context(s!("failed to compile inline plugin `{}`", &plugin.name))? - .render(&data) - .with_context(s!( - "failed to render inline plugin `{}`", - &plugin.name - ))?, - ); - script.push('\n'); + // Data to use in template rendering + let data = upon::value! { name: &plugin }; + let out = engine + .compile(&plugin.raw) + .with_context(s!("failed to compile inline plugin `{}`", &plugin.name))? + .render(&data) + .with_context(s!("failed to render inline plugin `{}`", &plugin.name))?; + script.push_str(&out); + if !out.ends_with('\n') { + script.push('\n'); + } status_v!(ctx, "Inlined", &plugin.name); } } diff --git a/tests/lib.rs b/tests/lib.rs index a3ed372b..a7eeeaff 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -41,16 +41,11 @@ impl TestCase { p }; - let xconfig = dirs.config.strip_prefix(dirs.home.path()).unwrap(); - let xdata = dirs.data.strip_prefix(dirs.home.path()).unwrap(); - let subs = upon::value! { version: env!("CARGO_PKG_VERSION"), home: dirs.home.path(), config: &dirs.config, - xconfig: xconfig, data: &dirs.data, - xdata: xdata, }; let mut data = HashMap::new(); @@ -402,7 +397,7 @@ fn directories_default() -> io::Result<()> { #[test] fn directories_xdg_default() -> io::Result<()> { let dirs = TestDirs::default_xdg()?; - let case = TestCase::load_with_dirs("directories", dirs)?; + let case = TestCase::load_with_dirs("directories_xdg_default", dirs)?; let xdg_cache = case.dirs.home.path().join(".cache"); let envs = [("XDG_CACHE_HOME", &xdg_cache)]; case.write_config_file("plugins.toml")?; @@ -414,9 +409,9 @@ fn directories_xdg_default() -> io::Result<()> { } #[test] -fn dirs_xdg_from_env() -> io::Result<()> { +fn directories_xdg_from_env() -> io::Result<()> { let dirs = TestDirs::new("config_custom/sheldon", ".local/custom/sheldon")?; - let case = TestCase::load_with_dirs("directories", dirs)?; + let case = TestCase::load_with_dirs("directories_xdg_from_env", dirs)?; let xdg_config = case.dirs.home.path().join("config_custom"); let xdg_data = case.dirs.home.path().join(".local/custom"); let envs = [ diff --git a/tests/testdata/clean/lock.stderr b/tests/testdata/clean/lock.stderr index 5944c294..21d1792d 100644 --- a/tests/testdata/clean/lock.stderr +++ b/tests/testdata/clean/lock.stderr @@ -1,3 +1,3 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [REMOVED] ~/.sheldon/repos/test.com -[LOCKED] ~//plugins.lock +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/clean/plugins.lock b/tests/testdata/clean/plugins.lock index 23244d7b..a4154775 100644 --- a/tests/testdata/clean/plugins.lock +++ b/tests/testdata/clean/plugins.lock @@ -4,18 +4,9 @@ config_dir = "" data_dir = "" config_file = "/plugins.toml" plugins = [] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/clean/source.stderr b/tests/testdata/clean/source.stderr index 0795fb60..2f3b14d3 100644 --- a/tests/testdata/clean/source.stderr +++ b/tests/testdata/clean/source.stderr @@ -1 +1 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/clean_permission_denied/lock.stderr b/tests/testdata/clean_permission_denied/lock.stderr index cf287fed..0f1203a2 100644 --- a/tests/testdata/clean_permission_denied/lock.stderr +++ b/tests/testdata/clean_permission_denied/lock.stderr @@ -1,5 +1,5 @@ -[LOADED] ~//plugins.toml -[LOCKED] ~//plugins.lock +[LOADED] ~/.sheldon/plugins.toml +[LOCKED] ~/.sheldon/plugins.lock [WARNING] failed to remove directory `~/.sheldon/repos/test.com` due to: Permission denied (os error 13) diff --git a/tests/testdata/clean_permission_denied/plugins.lock b/tests/testdata/clean_permission_denied/plugins.lock index 23244d7b..a4154775 100644 --- a/tests/testdata/clean_permission_denied/plugins.lock +++ b/tests/testdata/clean_permission_denied/plugins.lock @@ -4,18 +4,9 @@ config_dir = "" data_dir = "" config_file = "/plugins.toml" plugins = [] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/clean_permission_denied/source.stderr b/tests/testdata/clean_permission_denied/source.stderr index 0795fb60..2f3b14d3 100644 --- a/tests/testdata/clean_permission_denied/source.stderr +++ b/tests/testdata/clean_permission_denied/source.stderr @@ -1 +1 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/directories/lock.stderr b/tests/testdata/directories/lock.stderr index 5b5013a7..466e3a31 100644 --- a/tests/testdata/directories/lock.stderr +++ b/tests/testdata/directories/lock.stderr @@ -1,4 +1,4 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [FETCHED] https://raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh [CLONED] https://github.com/rossmacarthur/sheldon-test -[LOCKED] ~//plugins.lock +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/directories/plugins.lock b/tests/testdata/directories/plugins.lock index f27c0538..e0b6bc36 100644 --- a/tests/testdata/directories/plugins.lock +++ b/tests/testdata/directories/plugins.lock @@ -15,18 +15,9 @@ name = "testb" source_dir = "/repos/github.com/rossmacarthur/sheldon-test" files = ["/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"] apply = ["source"] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/directories/source.stderr b/tests/testdata/directories/source.stderr index b2cc3511..676e1c00 100644 --- a/tests/testdata/directories/source.stderr +++ b/tests/testdata/directories/source.stderr @@ -1,3 +1,3 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock [RENDERED] testa [RENDERED] testb diff --git a/tests/testdata/directories_xdg_default/lock.stderr b/tests/testdata/directories_xdg_default/lock.stderr new file mode 100644 index 00000000..1a2e467d --- /dev/null +++ b/tests/testdata/directories_xdg_default/lock.stderr @@ -0,0 +1,4 @@ +[LOADED] ~/.config/sheldon/plugins.toml + [FETCHED] https://raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh + [CLONED] https://github.com/rossmacarthur/sheldon-test +[LOCKED] ~/.local/share/sheldon/plugins.lock diff --git a/tests/testdata/directories_xdg_default/plugins.lock b/tests/testdata/directories_xdg_default/plugins.lock new file mode 100644 index 00000000..e0b6bc36 --- /dev/null +++ b/tests/testdata/directories_xdg_default/plugins.lock @@ -0,0 +1,23 @@ +version = "" +home = "" +config_dir = "" +data_dir = "" +config_file = "/plugins.toml" + +[[plugins]] +name = "testa" +source_dir = "/downloads/raw.githubusercontent.com/rossmacarthur/sheldon-test/master" +files = ["/downloads/raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh"] +apply = ["source"] + +[[plugins]] +name = "testb" +source_dir = "/repos/github.com/rossmacarthur/sheldon-test" +files = ["/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"] +apply = ["source"] + +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/directories_xdg_default/plugins.toml b/tests/testdata/directories_xdg_default/plugins.toml new file mode 100644 index 00000000..308ce0e6 --- /dev/null +++ b/tests/testdata/directories_xdg_default/plugins.toml @@ -0,0 +1,5 @@ +[plugins.testa] +remote = "https://raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh" + +[plugins.testb] +github = "rossmacarthur/sheldon-test" diff --git a/tests/testdata/directories_xdg_default/source.stderr b/tests/testdata/directories_xdg_default/source.stderr new file mode 100644 index 00000000..1065289a --- /dev/null +++ b/tests/testdata/directories_xdg_default/source.stderr @@ -0,0 +1,3 @@ +[UNLOCKED] ~/.local/share/sheldon/plugins.lock + [RENDERED] testa + [RENDERED] testb diff --git a/tests/testdata/directories_xdg_default/source.stdout b/tests/testdata/directories_xdg_default/source.stdout new file mode 100644 index 00000000..e135a643 --- /dev/null +++ b/tests/testdata/directories_xdg_default/source.stdout @@ -0,0 +1,2 @@ +source "/downloads/raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh" +source "/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh" diff --git a/tests/testdata/directories_xdg_from_env/lock.stderr b/tests/testdata/directories_xdg_from_env/lock.stderr new file mode 100644 index 00000000..39a068f9 --- /dev/null +++ b/tests/testdata/directories_xdg_from_env/lock.stderr @@ -0,0 +1,4 @@ +[LOADED] ~/config_custom/sheldon/plugins.toml + [FETCHED] https://raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh + [CLONED] https://github.com/rossmacarthur/sheldon-test +[LOCKED] ~/.local/custom/sheldon/plugins.lock diff --git a/tests/testdata/directories_xdg_from_env/plugins.lock b/tests/testdata/directories_xdg_from_env/plugins.lock new file mode 100644 index 00000000..e0b6bc36 --- /dev/null +++ b/tests/testdata/directories_xdg_from_env/plugins.lock @@ -0,0 +1,23 @@ +version = "" +home = "" +config_dir = "" +data_dir = "" +config_file = "/plugins.toml" + +[[plugins]] +name = "testa" +source_dir = "/downloads/raw.githubusercontent.com/rossmacarthur/sheldon-test/master" +files = ["/downloads/raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh"] +apply = ["source"] + +[[plugins]] +name = "testb" +source_dir = "/repos/github.com/rossmacarthur/sheldon-test" +files = ["/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"] +apply = ["source"] + +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/directories_xdg_from_env/plugins.toml b/tests/testdata/directories_xdg_from_env/plugins.toml new file mode 100644 index 00000000..308ce0e6 --- /dev/null +++ b/tests/testdata/directories_xdg_from_env/plugins.toml @@ -0,0 +1,5 @@ +[plugins.testa] +remote = "https://raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh" + +[plugins.testb] +github = "rossmacarthur/sheldon-test" diff --git a/tests/testdata/directories_xdg_from_env/source.stderr b/tests/testdata/directories_xdg_from_env/source.stderr new file mode 100644 index 00000000..ccc671d2 --- /dev/null +++ b/tests/testdata/directories_xdg_from_env/source.stderr @@ -0,0 +1,3 @@ +[UNLOCKED] ~/.local/custom/sheldon/plugins.lock + [RENDERED] testa + [RENDERED] testb diff --git a/tests/testdata/directories_xdg_from_env/source.stdout b/tests/testdata/directories_xdg_from_env/source.stdout new file mode 100644 index 00000000..e135a643 --- /dev/null +++ b/tests/testdata/directories_xdg_from_env/source.stdout @@ -0,0 +1,2 @@ +source "/downloads/raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh" +source "/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh" diff --git a/tests/testdata/empty/lock.stderr b/tests/testdata/empty/lock.stderr index 655075a1..f0c3f6df 100644 --- a/tests/testdata/empty/lock.stderr +++ b/tests/testdata/empty/lock.stderr @@ -1,2 +1,2 @@ -[LOADED] ~//plugins.toml -[LOCKED] ~//plugins.lock +[LOADED] ~/.sheldon/plugins.toml +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/empty/plugins.lock b/tests/testdata/empty/plugins.lock index 23244d7b..a4154775 100644 --- a/tests/testdata/empty/plugins.lock +++ b/tests/testdata/empty/plugins.lock @@ -4,18 +4,9 @@ config_dir = "" data_dir = "" config_file = "/plugins.toml" plugins = [] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/empty/source.stderr b/tests/testdata/empty/source.stderr index 0795fb60..2f3b14d3 100644 --- a/tests/testdata/empty/source.stderr +++ b/tests/testdata/empty/source.stderr @@ -1 +1 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/github_bad_reinstall/lock.stderr b/tests/testdata/github_bad_reinstall/lock.stderr index d861790c..8b0d52d1 100644 --- a/tests/testdata/github_bad_reinstall/lock.stderr +++ b/tests/testdata/github_bad_reinstall/lock.stderr @@ -1,4 +1,4 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [ERROR] failed to install source `https://github.com/rossmacarthur/sheldon-test@bad-tag` due to: failed to find tag `bad-tag` diff --git a/tests/testdata/github_bad_reinstall/plugins.lock b/tests/testdata/github_bad_reinstall/plugins.lock index ddc69413..95759dee 100644 --- a/tests/testdata/github_bad_reinstall/plugins.lock +++ b/tests/testdata/github_bad_reinstall/plugins.lock @@ -9,18 +9,9 @@ name = "test" source_dir = "/repos/github.com/rossmacarthur/sheldon-test" files = ["/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"] apply = ["source"] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/github_bad_url/lock.stderr b/tests/testdata/github_bad_url/lock.stderr index e1dea502..6a771861 100644 --- a/tests/testdata/github_bad_url/lock.stderr +++ b/tests/testdata/github_bad_url/lock.stderr @@ -1,4 +1,4 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [CLONED] https://github.com/rossmacarthur/sheldon-test [ERROR] failed to install source `https://github.com/rossmacarthur/sheldon-bad-url` diff --git a/tests/testdata/github_bad_url/source.stderr b/tests/testdata/github_bad_url/source.stderr index fd847274..1b08f5b9 100644 --- a/tests/testdata/github_bad_url/source.stderr +++ b/tests/testdata/github_bad_url/source.stderr @@ -1,4 +1,4 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [CHECKED] https://github.com/rossmacarthur/sheldon-test [RENDERED] test diff --git a/tests/testdata/github_branch/lock.stderr b/tests/testdata/github_branch/lock.stderr index d96e94db..8cdcd761 100644 --- a/tests/testdata/github_branch/lock.stderr +++ b/tests/testdata/github_branch/lock.stderr @@ -1,3 +1,3 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [CLONED] https://github.com/rossmacarthur/sheldon-test@feature -[LOCKED] ~//plugins.lock +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/github_branch/plugins.lock b/tests/testdata/github_branch/plugins.lock index ddc69413..95759dee 100644 --- a/tests/testdata/github_branch/plugins.lock +++ b/tests/testdata/github_branch/plugins.lock @@ -9,18 +9,9 @@ name = "test" source_dir = "/repos/github.com/rossmacarthur/sheldon-test" files = ["/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"] apply = ["source"] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/github_branch/source.stderr b/tests/testdata/github_branch/source.stderr index a5b476ff..773d9cfa 100644 --- a/tests/testdata/github_branch/source.stderr +++ b/tests/testdata/github_branch/source.stderr @@ -1,2 +1,2 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock [RENDERED] test diff --git a/tests/testdata/github_https/lock.stderr b/tests/testdata/github_https/lock.stderr index 3d104ec4..0baef708 100644 --- a/tests/testdata/github_https/lock.stderr +++ b/tests/testdata/github_https/lock.stderr @@ -1,3 +1,3 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [CLONED] https://github.com/rossmacarthur/sheldon-test -[LOCKED] ~//plugins.lock +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/github_https/plugins.lock b/tests/testdata/github_https/plugins.lock index ddc69413..95759dee 100644 --- a/tests/testdata/github_https/plugins.lock +++ b/tests/testdata/github_https/plugins.lock @@ -9,18 +9,9 @@ name = "test" source_dir = "/repos/github.com/rossmacarthur/sheldon-test" files = ["/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"] apply = ["source"] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/github_https/source.stderr b/tests/testdata/github_https/source.stderr index a5b476ff..773d9cfa 100644 --- a/tests/testdata/github_https/source.stderr +++ b/tests/testdata/github_https/source.stderr @@ -1,2 +1,2 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock [RENDERED] test diff --git a/tests/testdata/github_submodule/lock.stderr b/tests/testdata/github_submodule/lock.stderr index c7985efe..b37578f6 100644 --- a/tests/testdata/github_submodule/lock.stderr +++ b/tests/testdata/github_submodule/lock.stderr @@ -1,3 +1,3 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [CLONED] https://github.com/rossmacarthur/sheldon-test@recursive-recursive -[LOCKED] ~//plugins.lock +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/github_submodule/plugins.lock b/tests/testdata/github_submodule/plugins.lock index 76b72923..2c90931b 100644 --- a/tests/testdata/github_submodule/plugins.lock +++ b/tests/testdata/github_submodule/plugins.lock @@ -10,18 +10,9 @@ source_dir = "/repos/github.com/rossmacarthur/sheldon-test" plugin_dir = "/repos/github.com/rossmacarthur/sheldon-test/self/self" files = ["/repos/github.com/rossmacarthur/sheldon-test/self/self/test.plugin.zsh"] apply = ["source"] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/github_submodule/source.stderr b/tests/testdata/github_submodule/source.stderr index a5b476ff..773d9cfa 100644 --- a/tests/testdata/github_submodule/source.stderr +++ b/tests/testdata/github_submodule/source.stderr @@ -1,2 +1,2 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock [RENDERED] test diff --git a/tests/testdata/github_tag/lock.stderr b/tests/testdata/github_tag/lock.stderr index e12d42f2..8fda426d 100644 --- a/tests/testdata/github_tag/lock.stderr +++ b/tests/testdata/github_tag/lock.stderr @@ -1,3 +1,3 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [CLONED] https://github.com/rossmacarthur/sheldon-test@v0.1.0 -[LOCKED] ~//plugins.lock +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/github_tag/plugins.lock b/tests/testdata/github_tag/plugins.lock index ddc69413..95759dee 100644 --- a/tests/testdata/github_tag/plugins.lock +++ b/tests/testdata/github_tag/plugins.lock @@ -9,18 +9,9 @@ name = "test" source_dir = "/repos/github.com/rossmacarthur/sheldon-test" files = ["/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"] apply = ["source"] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/github_tag/source.stderr b/tests/testdata/github_tag/source.stderr index a5b476ff..773d9cfa 100644 --- a/tests/testdata/github_tag/source.stderr +++ b/tests/testdata/github_tag/source.stderr @@ -1,2 +1,2 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock [RENDERED] test diff --git a/tests/testdata/inline/lock.stderr b/tests/testdata/inline/lock.stderr index 3d104ec4..0baef708 100644 --- a/tests/testdata/inline/lock.stderr +++ b/tests/testdata/inline/lock.stderr @@ -1,3 +1,3 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [CLONED] https://github.com/rossmacarthur/sheldon-test -[LOCKED] ~//plugins.lock +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/inline/plugins.lock b/tests/testdata/inline/plugins.lock index 5486264a..3133499b 100644 --- a/tests/testdata/inline/plugins.lock +++ b/tests/testdata/inline/plugins.lock @@ -12,19 +12,10 @@ apply = ["source"] [[plugins]] name = "inline-test" -raw = "echo 'testing...'\n" -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false +raw = "echo 'testing...'" -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/inline/plugins.toml b/tests/testdata/inline/plugins.toml index 3774741d..87d9e191 100644 --- a/tests/testdata/inline/plugins.toml +++ b/tests/testdata/inline/plugins.toml @@ -2,6 +2,4 @@ github = "rossmacarthur/sheldon-test" [plugins.inline-test] -inline = """ -echo 'testing...' -""" +inline = "echo 'testing...'" diff --git a/tests/testdata/inline/source.stderr b/tests/testdata/inline/source.stderr index c1a7f693..4aae5a7d 100644 --- a/tests/testdata/inline/source.stderr +++ b/tests/testdata/inline/source.stderr @@ -1,3 +1,3 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock [RENDERED] test [INLINED] inline-test diff --git a/tests/testdata/inline/source.stdout b/tests/testdata/inline/source.stdout index e400a645..0b42a8ca 100644 --- a/tests/testdata/inline/source.stdout +++ b/tests/testdata/inline/source.stdout @@ -1,3 +1,2 @@ source "/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh" echo 'testing...' - diff --git a/tests/testdata/override_config_file/lock.stderr b/tests/testdata/override_config_file/lock.stderr index 120c923c..166c2ab4 100644 --- a/tests/testdata/override_config_file/lock.stderr +++ b/tests/testdata/override_config_file/lock.stderr @@ -1,2 +1,2 @@ -[LOADED] ~//test.toml -[LOCKED] ~//plugins.lock +[LOADED] ~/.sheldon/test.toml +[LOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/override_config_file/plugins.lock b/tests/testdata/override_config_file/plugins.lock index c1ef8ded..0172d494 100644 --- a/tests/testdata/override_config_file/plugins.lock +++ b/tests/testdata/override_config_file/plugins.lock @@ -4,18 +4,9 @@ config_dir = "" data_dir = "" config_file = "/test.toml" plugins = [] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/override_config_file/source.stderr b/tests/testdata/override_config_file/source.stderr index 0795fb60..2f3b14d3 100644 --- a/tests/testdata/override_config_file/source.stderr +++ b/tests/testdata/override_config_file/source.stderr @@ -1 +1 @@ -[UNLOCKED] ~//plugins.lock +[UNLOCKED] ~/.sheldon/plugins.lock diff --git a/tests/testdata/override_data_dir/lock.stderr b/tests/testdata/override_data_dir/lock.stderr index 0e50e7ac..4a00108d 100644 --- a/tests/testdata/override_data_dir/lock.stderr +++ b/tests/testdata/override_data_dir/lock.stderr @@ -1,2 +1,2 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [LOCKED] ~/test/plugins.lock diff --git a/tests/testdata/override_data_dir/plugins.lock b/tests/testdata/override_data_dir/plugins.lock index a24e1f33..651e2fc7 100644 --- a/tests/testdata/override_data_dir/plugins.lock +++ b/tests/testdata/override_data_dir/plugins.lock @@ -4,18 +4,9 @@ config_dir = "" data_dir = "/test" config_file = "/plugins.toml" plugins = [] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/profiles/lock.stderr b/tests/testdata/profiles/lock.stderr index f2af2703..e1859f99 100644 --- a/tests/testdata/profiles/lock.stderr +++ b/tests/testdata/profiles/lock.stderr @@ -1,4 +1,4 @@ -[LOADED] ~//plugins.toml +[LOADED] ~/.sheldon/plugins.toml [SKIPPED] https://github.com/rossmacarthur/sheldon-test2 [CLONED] https://github.com/rossmacarthur/sheldon-test -[LOCKED] ~//plugins.p1.lock +[LOCKED] ~/.sheldon/plugins.p1.lock diff --git a/tests/testdata/profiles/plugins.p1.lock b/tests/testdata/profiles/plugins.p1.lock index 5033f36b..eba8a581 100644 --- a/tests/testdata/profiles/plugins.p1.lock +++ b/tests/testdata/profiles/plugins.p1.lock @@ -13,20 +13,11 @@ apply = ["source"] [[plugins]] name = "inline-test" -raw = "echo 'testing...'\n" +raw = "echo 'testing...'" profiles = ["p1", "p2"] -[templates.PATH] -value = "export PATH=\"{{ dir }}:$PATH\"" -each = false -[templates.path] -value = "path=( \"{{ dir }}\" $path )" -each = false - -[templates.fpath] -value = "fpath=( \"{{ dir }}\" $fpath )" -each = false - -[templates.source] -value = "source \"{{ file }}\"" -each = true +[templates] +PATH = "export PATH=\"{{ dir }}:$PATH\"" +path = "path=( \"{{ dir }}\" $path )" +fpath = "fpath=( \"{{ dir }}\" $fpath )" +source = "{% for file in files %}source \"{{ file }}\"\n{% endfor %}" diff --git a/tests/testdata/profiles/plugins.toml b/tests/testdata/profiles/plugins.toml index 171308e9..cd88d2b3 100644 --- a/tests/testdata/profiles/plugins.toml +++ b/tests/testdata/profiles/plugins.toml @@ -7,13 +7,9 @@ github = "rossmacarthur/sheldon-test2" profiles = ["p2"] [plugins.inline-test] -inline = """ -echo 'testing...' -""" +inline = "echo 'testing...'" profiles = ["p1", "p2"] [plugins.inline-test2] -inline = """ -echo 'testing...' -""" +inline = "echo 'testing...'" profiles = ["p2"] diff --git a/tests/testdata/profiles/source.stderr b/tests/testdata/profiles/source.stderr index 2a3bfd2a..dc64b513 100644 --- a/tests/testdata/profiles/source.stderr +++ b/tests/testdata/profiles/source.stderr @@ -1,3 +1,3 @@ -[UNLOCKED] ~//plugins.p1.lock +[UNLOCKED] ~/.sheldon/plugins.p1.lock [RENDERED] test [INLINED] inline-test diff --git a/tests/testdata/profiles/source.stdout b/tests/testdata/profiles/source.stdout index e400a645..0b42a8ca 100644 --- a/tests/testdata/profiles/source.stdout +++ b/tests/testdata/profiles/source.stdout @@ -1,3 +1,2 @@ source "/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh" echo 'testing...' -