@@ -11,6 +11,7 @@ use anyhow::{anyhow, Result};
1111use markdown:: mdast:: Node ;
1212use regex:: Regex ;
1313use slim_protocol:: { Instruction , SlimConnection } ;
14+ use std:: collections:: HashMap ;
1415use std:: {
1516 fs:: read_to_string,
1617 io:: { Read , Write } ,
@@ -21,6 +22,21 @@ mod markdown_commands;
2122mod slim_instructions_from_commands;
2223mod validate_result;
2324
25+ #[ derive( Debug , Default ) ]
26+ pub struct State {
27+ symbols : HashMap < String , String > ,
28+ }
29+
30+ impl State {
31+ pub fn set_symbol ( & mut self , key : String , value : String ) {
32+ self . symbols . insert ( key, value) ;
33+ }
34+
35+ pub fn get_symbol ( & self , key : & str ) -> Option < & String > {
36+ self . symbols . get ( key)
37+ }
38+ }
39+
2440#[ derive( Debug , Clone ) ]
2541pub struct Filter {
2642 filters : Vec < FilterType > ,
@@ -91,9 +107,10 @@ pub fn execute_instructions_and_print_result<R: Read, W: Write>(
91107 instructions : Vec < Instruction > ,
92108 expected_result : Vec < ExpectedResulWithSnooze > ,
93109 show_snoozed : bool ,
110+ state : & mut State ,
94111) -> Result < bool > {
95112 let result = connection. send_instructions ( & instructions) ?;
96- let failures = validate_result ( file_path, expected_result, result) ?;
113+ let failures = validate_result ( file_path, expected_result, result, state ) ?;
97114 print_fail_or_ok ( show_snoozed, failures)
98115}
99116
0 commit comments