[latex3-commits] [git/l3build] master: New option --shuffle (see #46) (c7a03bd)
Joseph Wright
joseph.wright at morningstar2.co.uk
Tue Jan 9 23:51:30 CET 2018
Repository : https://github.com/latex3/l3build
On branch : master
Link : https://github.com/latex3/l3build/commit/c7a03bdc8002ea2237ec1228b2a6ec743d95fb3e
>---------------------------------------------------------------
commit c7a03bdc8002ea2237ec1228b2a6ec743d95fb3e
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Tue Jan 9 22:51:30 2018 +0000
New option --shuffle (see #46)
>---------------------------------------------------------------
c7a03bdc8002ea2237ec1228b2a6ec743d95fb3e
l3build-arguments.lua | 5 +++++
l3build-check.lua | 17 ++++++++++++++++-
l3build.dtx | 1 +
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/l3build-arguments.lua b/l3build-arguments.lua
index c4f6327..4767ddd 100644
--- a/l3build-arguments.lua
+++ b/l3build-arguments.lua
@@ -93,6 +93,11 @@ option_list =
short = "r",
type = "boolean"
},
+ shuffle =
+ {
+ desc = "Shuffle order of tests",
+ type = "boolean"
+ },
texmfhome =
{
desc = "Location of user texmf tree",
diff --git a/l3build-check.lua b/l3build-check.lua
index 67c9bab..d54e26d 100644
--- a/l3build-check.lua
+++ b/l3build-check.lua
@@ -28,6 +28,8 @@ local close = io.close
local write = io.write
local output = io.output
+local rnd = math.random
+
local len = string.len
local char = string.char
local format = string.format
@@ -726,7 +728,20 @@ function check(names)
end
end
end
- sort(names)
+ -- https://stackoverflow.com/a/32167188
+ local function shuffle(tbl)
+ local len, random = #tbl, rnd
+ for i = len, 2, -1 do
+ local j = random(1, i)
+ tbl[i], tbl[j] = tbl[j], tbl[i]
+ end
+ return tbl
+ end
+ if options["shuffle"] then
+ names = shuffle(names)
+ else
+ sort(names)
+ end
-- Actually run the tests
print("Running checks on")
local i = 0
diff --git a/l3build.dtx b/l3build.dtx
index 1e0329e..a946f68 100644
--- a/l3build.dtx
+++ b/l3build.dtx
@@ -329,6 +329,7 @@
% version rather than using a log comparison
% \item \texttt{--quiet} (\texttt{-q}) Suppresses output from unpacking
% \item \texttt{--rerun} (\texttt{-r}) Run tests without unpacking/set up
+% \item \texttt{--shuffle} Shuffle the order in whichs tests run
% \item \texttt{--texmfhome} Sets the location of the user tree for installing
% \item \texttt{--version} (\texttt{-v}) Version string to use when setting
% version data
More information about the latex3-commits
mailing list