Skip to content

Commit

Permalink
fix:(zpool): "see" line in status is not parsed correctly (#168)
Browse files Browse the repository at this point in the history
* Fix https url parsing, add test to verify
  • Loading branch information
s-burris authored Apr 14, 2022
1 parent f8beba0 commit b15d168
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["Andrey Cherkashin <[email protected]>"]
version = "0.2.3"
version = "0.2.4"
description = "libzetta is a stable interface for programmatic administration of ZFS"
repository = "https://github.com/Inner-Heaven/libzetta-rs"
keywords = ["zfs", "freebsd", "zol", "os", "open3"]
Expand Down
16 changes: 16 additions & 0 deletions src/parsers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ mod test {
}
}

#[test]
fn test_see_line_https() {
let see_line = " see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J\n";

parses_to! {
parser: StdoutParser,
input: see_line,
rule: Rule::see,
tokens: [
see(0, 63, [
url(8, 62)
])
]
}
}

#[test]
fn test_naked_good() {
let stdout_valid_two_disks = r#"pool: naked_test
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/stdout.pest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ alpha_num = _{ digit | alpha }
alpha_nums = _{ alpha_num+ }
text = _{ (alpha_num | whitespace |symbol)+ }
path = @{ !raid_enum ~ "/"? ~ (name ~ "/"?)+ }
url = @{ ("http" | "https") ~ ":/" ~ path }
url = @{ ("https" | "http") ~ ":/" ~ path }
state_enum = { "ONLINE" | "OFFLINE" | "UNAVAIL" | "DEGRADED" | "FAULTED" | "AVAIL"}
raid_enum = { "mirror" | "raidz1" | "raidz2" | "raidz3" }
raid_name = ${ raid_enum ~ ("-" ~ digits)? }
Expand Down Expand Up @@ -42,7 +42,7 @@ logs = { whitespace* ~ "logs" ~ whitespace* ~ "\n" ~ whitespace* ~ vdevs ~ "\n"?
caches = { whitespace* ~ "cache" ~ whitespace* ~ "\n" ~ whitespace* ~ disk_line+ ~ "\n"?}
spares = { whitespace* ~ "spares" ~ whitespace* ~ "\n" ~ whitespace* ~ disk_line+ ~ "\n"?}

zpool = { "\n"? ~ pool_name ~ pool_id? ~ state ~ status? ~ action? ~ scan_line? ~ see? ~ config ~ "\n" ~ pool_headers? ~ pool_line ~ vdevs ~ logs? ~ caches? ~ spares? ~ errors? ~ "\n"?}
zpool = { "\n"? ~ pool_name ~ pool_id? ~ state ~ status? ~ action? ~ see? ~ scan_line? ~ config ~ "\n" ~ pool_headers? ~ pool_line ~ vdevs ~ logs? ~ caches? ~ spares? ~ errors? ~ "\n"?}
zpools = _{ zpool* ~ whitespace* }

text_line = _{ text ~ "\n" }
Expand Down

0 comments on commit b15d168

Please sign in to comment.