Skip to content

Commit 0f038f5

Browse files
authored
Revert "[2/n] add newtype wrappers to ensure config identifier validity (#69)"
This reverts commit d0ecc79.
1 parent d0ecc79 commit 0f038f5

File tree

6 files changed

+61
-460
lines changed

6 files changed

+61
-460
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,3 @@ tokio = { version = "1.26", features = [ "full" ] }
3333
toml = "0.7.3"
3434
topological-sort = "0.2.2"
3535
walkdir = "2.3"
36-
37-
[dev-dependencies]
38-
proptest = "1.6.0"
39-
test-strategy = "0.4.0"

src/config/imp.rs renamed to src/config.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ use std::path::Path;
1212
use thiserror::Error;
1313
use topological_sort::TopologicalSort;
1414

15-
use super::PackageName;
16-
1715
/// Describes a set of packages to act upon.
1816
///
1917
/// This structure maps "package name" to "package"
20-
pub struct PackageMap<'a>(pub BTreeMap<&'a PackageName, &'a Package>);
18+
pub struct PackageMap<'a>(pub BTreeMap<&'a String, &'a Package>);
2119

2220
// The name of a file which should be created by building a package.
2321
#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -70,12 +68,12 @@ impl<'a> PackageMap<'a> {
7068
///
7169
/// Returns packages in batches that may be built concurrently.
7270
pub struct PackageDependencyIter<'a> {
73-
lookup_by_output: BTreeMap<OutputFile, (&'a PackageName, &'a Package)>,
71+
lookup_by_output: BTreeMap<OutputFile, (&'a String, &'a Package)>,
7472
outputs: TopologicalSort<OutputFile>,
7573
}
7674

7775
impl<'a> Iterator for PackageDependencyIter<'a> {
78-
type Item = Vec<(&'a PackageName, &'a Package)>;
76+
type Item = Vec<(&'a String, &'a Package)>;
7977

8078
fn next(&mut self) -> Option<Self::Item> {
8179
if self.outputs.is_empty() {
@@ -101,11 +99,11 @@ impl<'a> Iterator for PackageDependencyIter<'a> {
10199
}
102100

103101
/// Describes the configuration for a set of packages.
104-
#[derive(Clone, Deserialize, Debug)]
102+
#[derive(Deserialize, Debug)]
105103
pub struct Config {
106104
/// Packages to be built and installed.
107105
#[serde(default, rename = "package")]
108-
pub packages: BTreeMap<PackageName, Package>,
106+
pub packages: BTreeMap<String, Package>,
109107
}
110108

111109
impl Config {
@@ -156,24 +154,22 @@ pub fn parse<P: AsRef<Path>>(path: P) -> Result<Config, ParseError> {
156154

157155
#[cfg(test)]
158156
mod test {
159-
use crate::config::ServiceName;
160-
161157
use super::*;
162158

163159
#[test]
164160
fn test_order() {
165-
let pkg_a_name = PackageName::new_const("pkg-a");
161+
let pkg_a_name = String::from("pkg-a");
166162
let pkg_a = Package {
167-
service_name: ServiceName::new_const("a"),
163+
service_name: String::from("a"),
168164
source: PackageSource::Manual,
169165
output: PackageOutput::Tarball,
170166
only_for_targets: None,
171167
setup_hint: None,
172168
};
173169

174-
let pkg_b_name = PackageName::new_const("pkg-b");
170+
let pkg_b_name = String::from("pkg-b");
175171
let pkg_b = Package {
176-
service_name: ServiceName::new_const("b"),
172+
service_name: String::from("b"),
177173
source: PackageSource::Composite {
178174
packages: vec![pkg_a.get_output_file(&pkg_a_name)],
179175
},
@@ -202,10 +198,10 @@ mod test {
202198
#[test]
203199
#[should_panic(expected = "cyclic dependency in package manifest")]
204200
fn test_cyclic_dependency() {
205-
let pkg_a_name = PackageName::new_const("pkg-a");
206-
let pkg_b_name = PackageName::new_const("pkg-b");
201+
let pkg_a_name = String::from("pkg-a");
202+
let pkg_b_name = String::from("pkg-b");
207203
let pkg_a = Package {
208-
service_name: ServiceName::new_const("a"),
204+
service_name: String::from("a"),
209205
source: PackageSource::Composite {
210206
packages: vec![String::from("pkg-b.tar")],
211207
},
@@ -214,7 +210,7 @@ mod test {
214210
setup_hint: None,
215211
};
216212
let pkg_b = Package {
217-
service_name: ServiceName::new_const("b"),
213+
service_name: String::from("b"),
218214
source: PackageSource::Composite {
219215
packages: vec![String::from("pkg-a.tar")],
220216
},
@@ -240,9 +236,9 @@ mod test {
240236
#[test]
241237
#[should_panic(expected = "Could not find a package which creates 'pkg-b.tar'")]
242238
fn test_missing_dependency() {
243-
let pkg_a_name = PackageName::new_const("pkg-a");
239+
let pkg_a_name = String::from("pkg-a");
244240
let pkg_a = Package {
245-
service_name: ServiceName::new_const("a"),
241+
service_name: String::from("a"),
246242
source: PackageSource::Composite {
247243
packages: vec![String::from("pkg-b.tar")],
248244
},

0 commit comments

Comments
 (0)