Skip to content

Commit f54327c

Browse files
committed
automatically get windows_kill on Windows
1 parent d665f75 commit f54327c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/commonSetupOnce.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,20 @@ function commonSetupOnce(testCase)
2020
testCase.ListPid = @(name)"tasklist /fi ""IMAGENAME eq " + name + ".exe""";
2121
testCase.ReadPidList = @(file)readtable(file, "VariableNamingRule", "preserve", "NumHeaderLines", 3, "MultipleDelimsAsOne", true, "Delimiter", " ");
2222
testCase.ExtractPid = @(table)table.Var2;
23-
windows_killroot = string(getenv("WINDOWS_KILL_INSTALL"));
24-
assert(~isempty(windows_killroot), "WINDOWS_KILL_INSTALL environment must be defined.")
25-
testCase.Sigint = @(id)fullfile(windows_killroot,"windows-kill") + " -SIGINT " + id;
23+
windows_killroot = getenv("WINDOWS_KILL_INSTALL");
24+
windows_killname = "windows-kill";
25+
if isempty(windows_killroot)
26+
% windows_kill not pre-installed
27+
windows_kill_url = "https://github.com/ElyDotDev/windows-kill/releases/download/1.1.4";
28+
windows_kill_zipfilename = "windows-kill_x64_1.1.4_lib_release";
29+
windows_killroot = fullfile(tempdir, windows_kill_zipfilename);
30+
31+
% look for it in tempdir, download and install if it doesn't exist
32+
if ~exist(fullfile(windows_killroot, windows_killname + ".exe"),"file")
33+
unzip(fullfile(windows_kill_url, windows_kill_zipfilename + ".zip"), tempdir);
34+
end
35+
end
36+
testCase.Sigint = @(id)fullfile(windows_killroot,windows_killname) + " -SIGINT " + id;
2637
testCase.Sigterm = @(id)"taskkill /F /pid " + id;
2738
elseif isunix && ~ismac
2839
testCase.ListPid = @(name)"ps -C " + name;

0 commit comments

Comments
 (0)