[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72n-WocEegVc2-Em6muU4pOTOh+Lf8RAwiAtjuUUjnysbQ@mail.gmail.com>
Date: Thu, 15 Jun 2023 00:09:00 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: ojeda@...nel.org, alex.gaynor@...il.com, benno.lossin@...ton.me,
bjorn3_gh@...tonmail.com, boqun.feng@...il.com,
brendan.higgins@...ux.dev, davidgow@...gle.com, gary@...yguo.net,
kunit-dev@...glegroups.com, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org, nmi@...aspace.dk,
patches@...ts.linux.dev, philip.li@...el.com,
rust-for-linux@...r.kernel.org, wedsonaf@...il.com
Subject: Re: [PATCH 5/6] rust: support running Rust documentation tests as
KUnit ones
On Wed, Jun 14, 2023 at 10:38 PM Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> This could just be
>
> std::fs::write(path, body.as_bytes());
+1, simpler, less `use`s needed and less size:
320429 12736 368 333533 516dd
scripts/rustdoc_test_builder
314701 12440 368 327509 4ff55
scripts/rustdoc_test_builder
Thanks for the review!
Cheers,
Miguel
diff --git a/scripts/rustdoc_test_builder.rs b/scripts/rustdoc_test_builder.rs
index e3b7138fb4f9..e5894652f12c 100644
--- a/scripts/rustdoc_test_builder.rs
+++ b/scripts/rustdoc_test_builder.rs
@@ -15,8 +15,7 @@
//! from that. For the moment, we generate ourselves a new name,
`{file}_{number}` instead, in
//! the `gen` script (done there since we need to be aware of all the
tests in a given file).
-use std::fs::File;
-use std::io::{BufWriter, Read, Write};
+use std::io::Read;
fn main() {
let mut stdin = std::io::stdin().lock();
@@ -69,5 +68,5 @@ fn main() {
let path = format!("rust/test/doctests/kernel/{name}");
- write!(BufWriter::new(File::create(path).unwrap()), "{body}").unwrap();
+ std::fs::write(path, body.as_bytes()).unwrap();
}
Powered by blists - more mailing lists