Working on invoking the tests.
This commit is contained in:
		
							parent
							
								
									d7e870cba1
								
							
						
					
					
						commit
						a1f8cbe079
					
				| @ -37,31 +37,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
| 
 | ||||
| #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] | ||||
| async fn main_body() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     let args = std::env::args().skip(1); | ||||
|     if args.is_empty() { | ||||
|         let org_contents = read_stdin_to_string()?; | ||||
|         run_anonymous_compare(org_contents) | ||||
|     } else { | ||||
|         for arg in args { | ||||
|             run_compare_on_file(arg)? | ||||
|         } | ||||
|         Ok(()) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| fn read_stdin_to_string() -> Result<String, Box<dyn std::error::Error>> { | ||||
|     let mut stdin_contents = String::new(); | ||||
|     std::io::stdin() | ||||
|         .lock() | ||||
|         .read_to_string(&mut stdin_contents)?; | ||||
|     Ok(stdin_contents) | ||||
|     let test_config = TestConfig::TestLayer(TestLayer { | ||||
|         name: "foo", | ||||
|         children: vec![TestConfig::SingleFile(SingleFile { | ||||
|             file_path: Path::new("/tmp/test.org"), | ||||
|         })], | ||||
|     }); | ||||
|     Ok(()) | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| enum TestConfig<'s> { | ||||
|     TestLayer(TestLayer<'s>), | ||||
|     SingleFile(SingleFile<'s>), | ||||
|     AnonymousFile(AnonymousFile), | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| @ -72,19 +60,13 @@ struct TestLayer<'s> { | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| struct SingleFile<'s> { | ||||
|     file_path: &'s str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| struct AnonymousFile { | ||||
|     name: String, | ||||
|     file_path: &'s Path, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| enum TestResult<'s> { | ||||
|     ResultLayer(ResultLayer<'s>), | ||||
|     SingleFileResult(SingleFileResult<'s>), | ||||
|     AnonymousFileResult(AnonymousFileResult), | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| @ -95,18 +77,41 @@ struct ResultLayer<'s> { | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| struct SingleFileResult<'s> { | ||||
|     name: &'s str, | ||||
|     file_path: &'s Path, | ||||
|     status: TestStatus, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| struct AnonymousFileResult { | ||||
|     name: String, | ||||
| pub(crate) enum TestStatus { | ||||
|     Good, | ||||
|     Bad, | ||||
| } | ||||
| 
 | ||||
| impl<'s> TestConfig<'s> { | ||||
|     async fn run_test(&self) -> TestResult<'s> { | ||||
|         match self { | ||||
|             TestConfig::TestLayer(test) => TestResult::ResultLayer(test.run_test().await), | ||||
|             TestConfig::SingleFile(test) => TestResult::SingleFileResult(test.run_test().await), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl<'s> SingleFile<'s> { | ||||
|     fn run_test(&self) -> SingleFileResult<'s> { | ||||
|     async fn run_test(&self) -> SingleFileResult<'s> { | ||||
|         let result = run_compare_on_file(self.file_path); | ||||
|         // foo
 | ||||
|         SingleFileResult { | ||||
|             file_path: self.file_path, | ||||
|             status: if result.is_ok() { | ||||
|                 TestStatus::Good | ||||
|             } else { | ||||
|                 TestStatus::Bad | ||||
|             }, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl<'s> TestLayer<'s> { | ||||
|     async fn run_test(&self) -> ResultLayer<'s> { | ||||
|         todo!() | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander