From nobody Sun Feb 8 07:07:23 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 534711E5207 for ; Fri, 19 Dec 2025 09:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766136353; cv=none; b=HMCRoOIdGH/LFN8Ae3l0ELwDelo3mLPILU9k9EepxvaSiShyNWq0ifkGv19Tfkktv8t/m+oQU9PnPYXhI0yvM7C7OyHvrH51ouFB0xI4EiKD6LWHUJS1+EwZj/xsHJexiJkRStoE5v2icjx97DfMxUxOpuvL2vwTCXbzhb919ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766136353; c=relaxed/simple; bh=eAL3LC+2dHh9zMBn+hXpoAz7Jvm8uTTfKLQguRTeU5c=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Tl6KilCzgcMH0wA89wxoF/aHcPA2EG4QS0VqfMI/ViR+odLkNZ8dEjrQpF4L56H9uQaVCaiYz6FJRd9/lmOaX1PjW0By0BZLYKvvh5LAJz6ub48bR9YQl80wL7bphe+a4ceJXwH4MbI4FAhF4dWN6UT+RHGOuDOVsP44uDB1wHE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PTbGSqIn; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PTbGSqIn" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2a0d058fc56so22978545ad.3 for ; Fri, 19 Dec 2025 01:25:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766136352; x=1766741152; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=FDiA9++PSC1lAnu943IjFuSz/gL1rZEi0ur8htsl9Kk=; b=PTbGSqInE0e+O9rKa6U8v1gh+FYYaKgeE1N8wmN77PpVzeqQ1NyVNLL4QnGRuOgoHq cPy6HG/w63N69+VpkbhrfzpR+4o2w774obOJ6A/z/q+EGtij67+ocs6YI9VfJyFqC6Xy QBkRLkQ6JVdgjQ2fjnKg+Inr8Kh1oWlHgPg2Fj4WHJrmKZMYariHHBBwsNCK1zzF4iLC Xetunopi/P3F2KLisosEwlhN5L3cH1tmai4wWQQtItSsFBRx2/SqLIqSJVlD44/vkWEO VzDkG9LRNvPJz+ISbOq7B2yxhg11HBJJaI5YQoDbLPBCwy85xk6bmy0CfCJbvBx5xHkJ /Q2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766136352; x=1766741152; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FDiA9++PSC1lAnu943IjFuSz/gL1rZEi0ur8htsl9Kk=; b=ujJOiFPWo4DaunDwEQq9rnK3qTwc9bGWrYqk+p7P48ygtTQmTWx7r+MqMXdQfWgRNF +pyiJrGoiVF14sm3zGP6BkmSIjLC2gndHIq2zGheHtCONO0yI4aDpnMlZSXCAImXm4Bj r94vw3AOTFY3gpclx8DD3KX+FyiOO3SHvCiu/Jz/JAr+F8/FPFvRgcm4JAXswDhb8kSt lo4Rt/AQz05PUwje9gFvW+mg1AfDgC133PXZRrHSKEhiThzM3UyHTmqj+N9x/Pr0h9Z0 VpOB9pL7Zux6pUe5k8NtrKMB8hOCjPdsH0TtAe2McarqpUiE26RSJoPlFIRYoWo8Yw3b ucTw== X-Forwarded-Encrypted: i=1; AJvYcCV3q5ljw3wIT/D3Brnp2nB74+tsRBM7qXUyOhk96zfTYqXnaCyHntOXlYvugOr1J7FjETpOqsqJQOL9dUc=@vger.kernel.org X-Gm-Message-State: AOJu0YwqeD7iUzLTUmN4HXLHpY8WYx/iMS+N2mNYEfAnh6zPSCze3xEa sQTv1EIh4LOOoUMet5/8qIw0bD2lWTVBIuYP62kYFvONB1eA9WAHi6hsOqw9/giBzwMNCgMSJJx 0ceCE/r6sBUycQg== X-Google-Smtp-Source: AGHT+IFESw50RYH9ypgSn2SiV5z0LY9j1QZK87YYocisEWy4PFUqcOeZorDnuMip9BneY5uX4han6LJmRN+G/A== X-Received: from pjboh15.prod.google.com ([2002:a17:90b:3a4f:b0:34c:d212:cb7f]) (user=davidgow job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ce11:b0:2a0:c5b6:67de with SMTP id d9443c01a7336-2a2f2a3d5b0mr23777415ad.52.1766136351586; Fri, 19 Dec 2025 01:25:51 -0800 (PST) Date: Fri, 19 Dec 2025 17:25:36 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.322.g1dd061c0dc-goog Message-ID: <20251219092537.1227513-1-davidgow@google.com> Subject: [RFC PATCH] rust: doctests: Number tests by line numerically, not lexicographically. From: David Gow To: Brendan Higgins , Rae Moar , Gary Guo , Miguel Ojeda , Shuah Khan , Guillaume Gomez Cc: David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The rust doctests are numbered -- instead of named with the line number -- in order to keep them moderately consistent even as the source file changes. However, the test numbers are generated by sorting the file/line strings, and so the line numbers were sorted as strings, not integers. So, for instance, a test on line 7 would sort in-between one on line 65 and one on line 75. Instead, parse the numbers as an integer, and sort based on that. This is a bit slower, uglier, and will break things once, but I suspect is worth it (at least until we have a better solution). Signed-off-by: David Gow --- This is a pretty unpolished, likely-unidiomatic patch to work around the test numbering being horrible. I have three questions before I decide if this is worth continuing with: 1. Is it worth renumbering all of the tests (hopefully just once), or would that break too many people's test histories? 2. Is there a better way of doing this in Rust? I can think of ways which might be nicer if the whole thing is refactored somewhat seriously, but if there's an easy numeric sort on strings, that'd be much easier. 3. Should we wait until after all or some of the changes to the test generation? Does the new --output-format=3Ddoctest option make this easier/harder/different? Does anyone have opinions/advice on those (or, indeed, on anything else)? Cheers, -- David --- scripts/rustdoc_test_gen.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs index be0561049660..60b0bbfb1896 100644 --- a/scripts/rustdoc_test_gen.rs +++ b/scripts/rustdoc_test_gen.rs @@ -116,7 +116,19 @@ fn main() { .collect::>(); =20 // Sort paths. - paths.sort(); + paths.sort_by(|a, b|{ + let a_name =3D a.file_name().unwrap().to_str().unwrap().to_string(= ); + let (a_file, a_line) =3D a_name.rsplit_once('_').unwrap().0.rsplit= _once('_').unwrap(); + let a_line_no =3D a_line.parse::().unwrap(); + let b_name =3D b.file_name().unwrap().to_str().unwrap().to_string(= ); + let (b_file, b_line) =3D b_name.rsplit_once('_').unwrap().0.rsplit= _once('_').unwrap(); + let b_line_no =3D b_line.parse::().unwrap(); + + match a_file.cmp(b_file) { + std::cmp::Ordering::Equal =3D> a_line_no.cmp(&b_line_no), + order =3D> order, + } + }); =20 let mut rust_tests =3D String::new(); let mut c_test_declarations =3D String::new(); --=20 2.52.0.322.g1dd061c0dc-goog