Re: [PATCH 5/6] rust: support running Rust documentation tests as KUnit ones

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 14, 2023 at 10:38 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> 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();
 }




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux