Fixup tests

This commit is contained in:
Till Wegmueller 2021-04-24 19:13:41 -03:00
parent 54709d1cc5
commit 5b52c8565a
3 changed files with 22 additions and 29 deletions

View file

@ -61,7 +61,7 @@ transform_character = {
transform_action = @{ transform_character*} transform_action = @{ transform_character*}
transform = {"<transform " ~ action_name ~ " " ~ property+ ~ " "? ~ "->" ~ " "? ~ transform_action ~ ">" } transform = {"<transform " ~ action_name ~ " " ~ property+ ~ " "? ~ "->" ~ " "? ~ transform_action ~ ">" }
property_name = @{ ( ASCII_ALPHANUMERIC | "." | "_" | "-" )+ } property_name = @{ ( ASCII_ALPHANUMERIC | "." | "_" | "-" | "/" )+ }
property_value = @{ ( ASCII_ALPHANUMERIC | "/" | "," | "." | "_" | "-" | "%" | "*" | "@" | "(" | ")" | "$" | ":" | "+" | "'" | "\\" )+ | quoted_string } property_value = @{ ( ASCII_ALPHANUMERIC | "/" | "," | "." | "_" | "-" | "%" | "*" | "@" | "(" | ")" | "$" | ":" | "+" | "'" | "\\" )+ | quoted_string }
payload = @{ property_value } payload = @{ property_value }
property = { property_name ~ "=" ~ property_value } property = { property_name ~ "=" ~ property_value }

View file

@ -486,8 +486,7 @@ impl Manifest {
let str_val: String = prop.as_str().clone().into(); let str_val: String = prop.as_str().clone().into();
property.value = str_val property.value = str_val
.replace("\"", "") .replace("\"", "")
.replace("\\", "") .replace("\\", "");
.replace("\'", "");
} }
_ => panic!("unexpected rule {:?} inside action expected property_name or property_value", prop.as_rule()) _ => panic!("unexpected rule {:?} inside action expected property_name or property_value", prop.as_rule())
} }
@ -595,7 +594,6 @@ fn split_property(property_string: String) -> (String, String) {
String::from(v[1]) String::from(v[1])
.replace("\"", "") .replace("\"", "")
.replace("\\", "") .replace("\\", "")
.replace("\'", "")
) )
}, },
None => (property_string.clone(), String::new()) None => (property_string.clone(), String::new())

View file

@ -23,7 +23,7 @@ extern crate maplit;
mod tests { mod tests {
use crate::actions::{Manifest, Property, Dir, File, Dependency, Facet}; use crate::actions::{Manifest, Property, Dir, File, Dependency, Facet};
use crate::actions::{parse_manifest_string, Attr}; use crate::actions::{Attr};
use std::collections::{HashMap}; use std::collections::{HashMap};
use crate::payload::Payload; use crate::payload::Payload;
use crate::digest::{Digest, DigestAlgorithm, DigestSource}; use crate::digest::{Digest, DigestAlgorithm, DigestSource};
@ -33,22 +33,22 @@ mod tests {
#[test] #[test]
fn parse_attributes() { fn parse_attributes() {
let manifest_string = String::from("set name=pkg.fmri value=pkg://openindiana.org/web/server/nginx@1.18.0,5.11-2020.0.1.0:20200421T195136Z let manifest_string = String::from("set name=pkg.fmri value=pkg://openindiana.org/web/server/nginx@1.18.0,5.11-2020.0.1.0:20200421T195136Z
set name=com.oracle.info.name value=nginx value=test set name=com.oracle.info.name value=nginx value=test
set name=userland.info.git-remote value=git://github.com/OpenIndiana/oi-userland.git set name=userland.info.git-remote value=git://github.com/OpenIndiana/oi-userland.git
set name=userland.info.git-branch value=HEAD set name=userland.info.git-branch value=HEAD
set name=userland.info.git-rev value=1665491ba61bd494bf73e2916cd2250f3024260e set name=userland.info.git-rev value=1665491ba61bd494bf73e2916cd2250f3024260e
set name=pkg.summary value=\"Nginx Webserver\" set name=pkg.summary value=\"Nginx Webserver\"
set name=info.classification value=\"org.opensolaris.category.2008:Web Services/Application and Web Servers\" set name=info.classification value=\"org.opensolaris.category.2008:Web Services/Application and Web Servers\"
set name=info.upstream-url value=http://nginx.net/ set name=info.upstream-url value=http://nginx.net/
set name=info.source-url value=http://nginx.org/download/nginx-1.18.0.tar.gz set name=info.source-url value=http://nginx.org/download/nginx-1.18.0.tar.gz
set name=org.opensolaris.consolidation value=userland set name=org.opensolaris.consolidation value=userland
set name=com.oracle.info.version value=1.18.0 set name=com.oracle.info.version value=1.18.0
set name=pkg.summary value=\\\"provided mouse accessibility enhancements\\\" set name=pkg.summary value=\"provided mouse accessibility enhancements\"
set name=info.upstream value=X.Org Foundation set name=info.upstream value=\"X.Org Foundation\"
set name=pkg.description value=Latvian language support's extra files set name=pkg.description value=\"Latvian language support's extra files\"
set name=variant.arch value=i386 optional=testing optionalWithString=\"test ing\" set name=variant.arch value=i386 optional=testing optionalWithString=\"test ing\"
set name=info.source-url value=http://www.pgpool.net/download.php?f=pgpool-II-3.3.1.tar.gz set name=info.source-url value=\"http://www.pgpool.net/download.php?f=pgpool-II-3.3.1.tar.gz\"
set name=pkg.summary value=\\\"'XZ Utils - loss-less file compression application and library.'\\\""); set name=pkg.summary value=\"'XZ Utils - loss-less file compression application and library.'\"");
let mut optional_hash = HashMap::new(); let mut optional_hash = HashMap::new();
optional_hash.insert(String::from("optional"), Property{key: String::from("optional"), value:String::from("testing")}); optional_hash.insert(String::from("optional"), Property{key: String::from("optional"), value:String::from("testing")});
@ -142,14 +142,9 @@ mod tests {
} }
]; ];
let mut manifest = Manifest::new(); let res = Manifest::parse_string(manifest_string);
match parse_manifest_string(manifest_string) { assert!(res.is_ok(), "error during Manifest parsing: {:?}", res);
Ok(m) => manifest = m, let manifest = res.unwrap();
Err(e) => {
println!("{}", e);
assert!(false, "caught error");
}
};
assert_eq!(manifest.attributes.len(), 17); assert_eq!(manifest.attributes.len(), 17);