Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

step line numbers are recorded when protocol is loaded (#65) #121

Merged
merged 3 commits into from
Mar 28, 2019

Conversation

hallettj
Copy link
Contributor

@hallettj hallettj commented Mar 6, 2019

Adds a failing test that asserts that the line number for each protocol step is recorded when loading a protocol. fixes #65

@soenkehahn

@ghost ghost assigned hallettj Mar 6, 2019
@ghost ghost added the in progress label Mar 6, 2019
@hallettj hallettj requested a review from soenkehahn March 6, 2019 18:23
@matthandlersux
Copy link
Contributor

i hadn't heard about draft pull requests yet :)

@matthandlersux matthandlersux added this to In Progress in Originate/scriptkeeper Mar 19, 2019
@hallettj
Copy link
Contributor Author

I have an upstream pull request with yaml-rust here:

chyh1990/yaml-rust#125

I have updated the branch in this PR to use my fork of yaml-rust, report line numbers in error messages, and adjust tests as necessary to match the new output.

@hallettj hallettj marked this pull request as ready for review March 26, 2019 19:00
Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@matthandlersux matthandlersux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/protocol/mod.rs Show resolved Hide resolved
executable: PathBuf::from("foo"),
arguments: vec![],
}),
Marker { line: 1, col: 0 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the marker is a default value, what do you think about making the function above step_with_default_marker and not specifying the marker explicitly in the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was kinda torn on this. The tests make an equality comparison between Step values, and if the marker is not specified correctly in the expected value then the test will fail. We could change the tests to compare specific properties within a Step instead of the whole structure - for example we could compare just the command and arguments. In that case calling Step::new would suffice instead of step_with_marker.

Honestly I'm trying to suppress my instinct to put multiple assertions in a test (to check equality for command and arguments) in favor of the idea of testing just one thing in each test. I suppose I could put the commands and arguments into tuples for comparisons to technically get one assertion. I might make that change.

@@ -514,6 +540,12 @@ mod load {
Ok(result.into_iter().next().unwrap())
}

fn step_with_marker(command_matcher: CommandMatcher, marker: Marker) -> Step {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i assume you had to duplicate the function above because here it is in a different sub mod? i ran into this same issue at one point and wasn't sure the best way to share the function between both. seems like you could either add a larger surrounding mod (and move the function up a level), or import the function from the other one like use super::mod_name::function_name. not sure what the best rusty way to do it is, curious what you and @soenkehahn think though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not think of importing from a sibling module. Maybe I could move step_with_marker into a test helper module. I try not to worry too much about duplicating code in tests. But there is no reason for duplication if it is easy to avoid.

src/protocol/yaml.rs Show resolved Hide resolved
@hallettj hallettj merged commit 9638fc8 into master Mar 28, 2019
Originate/scriptkeeper automation moved this from In Progress to Done Mar 28, 2019
@hallettj hallettj deleted the jh/indicate-failing-step branch March 28, 2019 21:31
soenkehahn added a commit that referenced this pull request Mar 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging this pull request may close these issues.

when test fails, indicate which step failed more clearly
3 participants