Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RDruon committed Mar 18, 2024
1 parent 9c81ef1 commit 8d1b900
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tracing = "0.1"
tracing-subscriber = "0.3"

[dev-dependencies]
include_dir = "0.7"
include_dir = {version = "0.7", features = ["glob"]}
insta = "1"

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion src/ldlm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 DDN. All rights reserved.
// Copyright (c) 2024 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

Expand Down
6 changes: 3 additions & 3 deletions src/llite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
stats_parser::stats,
Param, Record, Stat, Target, TargetStats,
};
use combine::{attempt, choice, parser::char::string, ParseError, Parser, Stream};
use combine::{parser::char::string, ParseError, Parser, Stream};

pub(crate) const LLITE: &str = "llite";
pub(crate) const STATS: &str = "stats";
Expand All @@ -25,7 +25,7 @@ where
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
(
attempt(string(LLITE)).skip(period()),
string(LLITE).skip(period()),
target().skip(period()),
)
.map(|(_, x)| x)
Expand All @@ -41,7 +41,7 @@ where
I: Stream<Token = char>,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
choice(((param(STATS), stats().map(LliteStat::Stats)).message("while parsing llite_stat"),))
(param(STATS), stats().map(LliteStat::Stats)).message("while parsing llite_stat")
}

pub(crate) fn parse<I>() -> impl Parser<I, Output = Record>
Expand Down
23 changes: 14 additions & 9 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,26 @@ mod tests {
use include_dir::{include_dir, Dir};
use insta::assert_debug_snapshot;

static VALID_FIXTURES: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src/fixtures/valid");
static VALID_FIXTURES: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src/fixtures/valid/");

#[test]
fn test_valid_fixtures() {
for file in VALID_FIXTURES.files() {
let name = file.path().file_name().unwrap().to_string_lossy();
for dir in VALID_FIXTURES.find("*").unwrap() {
match dir {
include_dir::DirEntry::Dir(_) => {},
include_dir::DirEntry::File(file) => {
let name = file.path().to_string_lossy();

let contents = file.contents_utf8().unwrap();
let contents = file.contents_utf8().unwrap();

let result = parse()
.easy_parse(contents)
.map_err(|err| err.map_position(|p| p.translate_position(contents)))
.unwrap();
let result = parse()
.easy_parse(contents)
.map_err(|err| err.map_position(|p| p.translate_position(contents)))
.unwrap();

assert_debug_snapshot!(format!("valid_fixture_{name}"), result);
assert_debug_snapshot!(format!("valid_fixture_{name}"), result);
}
}
}
}

Expand Down

0 comments on commit 8d1b900

Please sign in to comment.