From 837b4ed9bcb26161384d7af66f919f8fcb512fce Mon Sep 17 00:00:00 2001 From: Calder Coalson Date: Tue, 16 Apr 2024 08:07:04 -0700 Subject: [PATCH] Fix README test. --- .pre-commit-config.yaml | 34 ++++++++++++++++++++++++++++++++++ README.md | 4 ++-- tests/goldenfiles/file1.txt | 2 +- tests/goldenfiles/file2.txt | 2 +- tests/goldenfiles/panic.txt | 2 +- tests/goldenfiles/update1.txt | 2 +- tests/goldenfiles/update2.txt | 2 +- tests/readme_usage.rs | 4 ++-- 8 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f15c915 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +exclude: | + (?x)^(tests/.*/.*\.(out|parse))$ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files +- repo: local + hooks: + - id: cargo-fmt + name: Cargo fmt + description: Run cargo fmt. + entry: cargo fmt + language: system + types: [rust] + pass_filenames: false + - id: cargo-test + name: Cargo test + description: Run cargo test. + entry: cargo test + language: system + types: [rust] + pass_filenames: false + - id: clippy + name: Clippy + description: Run clippy. + entry: cargo clippy + language: system + args: ["--", "-D", "warnings"] + types: [rust] + pass_filenames: false diff --git a/README.md b/README.md index c066e8a..84039d8 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ fn test() { let mut file1 = mint.new_goldenfile("file1.txt").unwrap(); let mut file2 = mint.new_goldenfile("file2.txt").unwrap(); - write!(file1, "Hello world!").unwrap(); - write!(file2, "Foo bar!").unwrap(); + writeln!(file1, "Hello world!").unwrap(); + writeln!(file2, "Foo bar!").unwrap(); } ``` diff --git a/tests/goldenfiles/file1.txt b/tests/goldenfiles/file1.txt index 6769dd6..cd08755 100644 --- a/tests/goldenfiles/file1.txt +++ b/tests/goldenfiles/file1.txt @@ -1 +1 @@ -Hello world! \ No newline at end of file +Hello world! diff --git a/tests/goldenfiles/file2.txt b/tests/goldenfiles/file2.txt index 995ced6..a882363 100644 --- a/tests/goldenfiles/file2.txt +++ b/tests/goldenfiles/file2.txt @@ -1 +1 @@ -Foo bar! \ No newline at end of file +Foo bar! diff --git a/tests/goldenfiles/panic.txt b/tests/goldenfiles/panic.txt index 489ce0f..3367afd 100644 --- a/tests/goldenfiles/panic.txt +++ b/tests/goldenfiles/panic.txt @@ -1 +1 @@ -old \ No newline at end of file +old diff --git a/tests/goldenfiles/update1.txt b/tests/goldenfiles/update1.txt index 6769dd6..cd08755 100644 --- a/tests/goldenfiles/update1.txt +++ b/tests/goldenfiles/update1.txt @@ -1 +1 @@ -Hello world! \ No newline at end of file +Hello world! diff --git a/tests/goldenfiles/update2.txt b/tests/goldenfiles/update2.txt index f6ea049..323fae0 100644 --- a/tests/goldenfiles/update2.txt +++ b/tests/goldenfiles/update2.txt @@ -1 +1 @@ -foobar \ No newline at end of file +foobar diff --git a/tests/readme_usage.rs b/tests/readme_usage.rs index e9410ae..98628cf 100644 --- a/tests/readme_usage.rs +++ b/tests/readme_usage.rs @@ -10,6 +10,6 @@ fn test() { let mut file1 = mint.new_goldenfile("file1.txt").unwrap(); let mut file2 = mint.new_goldenfile("file2.txt").unwrap(); - write!(file1, "Hello world!").unwrap(); - write!(file2, "Foo bar!").unwrap(); + writeln!(file1, "Hello world!").unwrap(); + writeln!(file2, "Foo bar!").unwrap(); }