Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Rust CI
on: [push, pull_request]

jobs:
build_linux:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust
run: |
rustup component add rustfmt
rustup component add clippy

- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-registry-linux

- name: Cache Cargo build
uses: actions/cache@v3
with:
path: target
key: cargo-build-linux

- name: Run tests
run: cargo test --verbose

- name: Run tests (release)
run: cargo test --verbose --release

- name: Run Cargo Clippy
run: cargo clippy

- name: Run Cargo Format
run: cargo fmt --check

- name: Run Cargo Doc
run: cargo doc --no-deps

build_osx:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-registry-osx

- name: Cache Cargo build
uses: actions/cache@v3
with:
path: target
key: cargo-build-osx

- name: Run tests
run: cargo test

- name: Run tests (release)
run: cargo test --release

build_win:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-registry-windows

- name: Cache Cargo build
uses: actions/cache@v3
with:
path: target
key: cargo-build-windows

- name: Run tests
run: cargo test

- name: Run tests (release)
run: cargo test --release
34 changes: 28 additions & 6 deletions src/pace/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ pub trait InstanceVisitor {
fn visit_unrecognized_line(&mut self, _lineno: usize, _line: &str) -> Action {
Action::Continue
}
fn visit_stride_line(&mut self, _lineno: usize, _line: &str, _key : &str, _value : &str) -> Action {
fn visit_stride_line(
&mut self,
_lineno: usize,
_line: &str,
_key: &str,
_value: &str,
) -> Action {
Action::Continue
}
}
Expand Down Expand Up @@ -161,7 +167,9 @@ impl<'a, V: InstanceVisitor> InstanceReader<'a, V> {
} else if content.starts_with("#s") {
// stride line in the format "#s key: value"
if let Some((key, value)) = try_parse_stride_line(content) {
if self.visitor.visit_stride_line(lineno, content, key, value) == Action::Terminate {
if self.visitor.visit_stride_line(lineno, content, key, value)
== Action::Terminate
{
return Ok(());
}
} else {
Expand Down Expand Up @@ -247,8 +255,15 @@ mod tests {
Action::Continue
}

fn visit_stride_line(&mut self, lineno: usize, line: &str, key: &str, value: &str) -> Action {
self.stride_lines.push((lineno, line.to_string(), key.to_string(), value.to_string()));
fn visit_stride_line(
&mut self,
lineno: usize,
line: &str,
key: &str,
value: &str,
) -> Action {
self.stride_lines
.push((lineno, line.to_string(), key.to_string(), value.to_string()));
Action::Continue
}
}
Expand Down Expand Up @@ -326,7 +341,14 @@ mod tests {
let mut reader = InstanceReader::new(&mut visitor);
reader.read(input.as_bytes()).unwrap();

assert_eq!(visitor.stride_lines,
vec![(1, "#s stride_key: somevalue".to_string(), "stride_key".to_string(), "somevalue".to_string())]);
assert_eq!(
visitor.stride_lines,
vec![(
1,
"#s stride_key: somevalue".to_string(),
"stride_key".to_string(),
"somevalue".to_string()
)]
);
}
}
Loading