Skip to content

Commit

Permalink
feat(zfs): Fix dataset name parser for ZFS (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
andoriyu authored Mar 22, 2020
1 parent 2d53272 commit db90fc7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parsers/zfs.pest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ symbol = _{ "!" | "@" | "," | "." | ";" | ":" | "/" | "\'" | "\"" | "(" | ")" |
alpha_num = _{ digit | alpha }
alpha_nums = _{ alpha_num+ }
text = _{ (alpha_num | whitespace |symbol)+ }
path_segment = _{ alpha_num ~ ("_" | "-" | "."| alpha_num)* }
path_segment = _{ ("_" | "-" | "."| alpha_num)+ }
snapshot_segment = _{ "@" ~ path_segment}
bookmark_segment = _{ "#" ~ path_segment}
dataset_name = { path_segment ~ ( "/" ~ path_segment)* ~ ( snapshot_segment | bookmark_segment )? }
Expand Down
49 changes: 49 additions & 0 deletions src/parsers/zfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,53 @@ bookmark z/var/mail#backup-2019-08-08
assert_eq!(expected[idx], (dataset_type.as_str(), dataset_name.as_str()));
}
}

#[test]
fn test_issue_126() {
let lines = r#"z/ROOT
z/ROOT/default
z/docker
z/iohyve
z/iohyve/Firmware
z/iohyve/ISO
z/iohyve/ISO/rancheros-v1.4.0.iso
z/iohyve/rancher
z/portshaker
z/portshaker/cache
z/portshaker/cache/andoriyu-local
z/portshaker/cache/freebsd-svn
z/portshaker/cache/vscode-git
z/poudriere
z/poudriere/data
z/poudriere/data/.m
z/poudriere/data/cache
z/poudriere/data/logs
z/poudriere/data/packages
z/poudriere/data/wrkdirs
z/poudriere/jails
z/poudriere/jails/live
z/poudriere/ports
z/poudriere/ports/dev
z/poudriere/ports/prestine
z/poudriere/ports/system
z/tmp
z/usr
z/usr/home
z/usr/ports
z/usr/ports/distfiles
z/usr/src
z/var
z/var/ccache
z/var/crash
z/var/log
z/var/mail
z/var/tmp
"#;


let mut pairs = ZfsParser::parse(Rule::datasets, lines).unwrap();
let datasets_pairs = pairs.next().unwrap().into_inner();
assert_eq!(38, datasets_pairs.clone().count());

}
}

0 comments on commit db90fc7

Please sign in to comment.