File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed
Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change 11use anyhow:: Result ;
22use assert_cmd:: Command ;
3- use insta:: { assert_yaml_snapshot , assert_snapshot } ;
3+ use insta:: { assert_snapshot , assert_yaml_snapshot } ;
44use lintrunner:: lint_message:: { LintMessage , LintSeverity } ;
55use regex:: Regex ;
66use serde_json;
@@ -703,3 +703,50 @@ fn tee_json() -> Result<()> {
703703
704704 Ok ( ( ) )
705705}
706+
707+ #[ test]
708+ fn linter_replacement_trailing_newlines ( ) -> Result < ( ) > {
709+ let data_path = tempfile:: tempdir ( ) ?;
710+ let lint_message = LintMessage {
711+ path : Some ( "tests/fixtures/fake_source_file.rs" . to_string ( ) ) ,
712+ line : Some ( 9 ) ,
713+ char : Some ( 1 ) ,
714+ code : "DUMMY" . to_string ( ) ,
715+ name : "dummy failure" . to_string ( ) ,
716+ severity : LintSeverity :: Advice ,
717+ original : Some (
718+ "\
719+ foo \n \
720+ bar \n \
721+ baz \n \
722+ foo \n \
723+ "
724+ . to_string ( ) ,
725+ ) ,
726+ replacement : Some (
727+ "\
728+ foo\n \
729+ bar\n \
730+ baz\n \
731+ foo\n \
732+ "
733+ . to_string ( ) ,
734+ ) ,
735+ description : Some ( "A dummy linter failure" . to_string ( ) ) ,
736+ } ;
737+ let config = temp_config_returning_msg ( lint_message) ?;
738+
739+ let mut cmd = Command :: cargo_bin ( "lintrunner" ) ?;
740+ cmd. arg ( format ! ( "--config={}" , config. path( ) . to_str( ) . unwrap( ) ) ) ;
741+ cmd. arg ( format ! (
742+ "--data-path={}" ,
743+ data_path. path( ) . to_str( ) . unwrap( )
744+ ) ) ;
745+ cmd. arg ( format ! ( "--force-color" ) ) ;
746+ // Run on a file to ensure that the linter is run.
747+ cmd. arg ( "README.md" ) ;
748+ cmd. assert ( ) . failure ( ) ;
749+ assert_output_snapshot ( "linter_replacement_trailing_newlines" , & mut cmd) ?;
750+
751+ Ok ( ( ) )
752+ }
You can’t perform that action at this time.
0 commit comments