Mercurial > octave
changeset 29027:c01950bc7290
maint: merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 05 Nov 2020 18:08:55 +0100 |
parents | 7f103819617d (current diff) 64d1c7af5b18 (diff) |
children | ba5a0edff85e |
files | scripts/pkg/private/configure_make.m scripts/pkg/private/install.m |
diffstat | 2 files changed, 53 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/pkg/private/configure_make.m Thu Nov 05 07:46:50 2020 -0800 +++ b/scripts/pkg/private/configure_make.m Thu Nov 05 18:08:55 2020 +0100 @@ -110,6 +110,39 @@ error ("pkg: error running 'make' for the %s package", desc.name); endif endif + + ## Extract tests from source files which will not to be installed + tst_files_src = []; + for suffix = {"*.cc", "*.c", "*.C", "*.cpp", "*.cxx"} + tst_files_src = [tst_files_src; ... + nthargout(1, 1, @dir, fullfile (src, suffix{1}))]; + endfor + if (! isempty (tst_files_src)) + for tst_file_src = {tst_files_src.name} + full_tst_file_src = fullfile (src, tst_file_src{1}); + tst_code = __extract_test_code__ (full_tst_file_src); + if (isempty (tst_code)) + continue; + endif + full_tst_file = strcat (full_tst_file_src, "-tst"); + if (exist (full_tst_file)) + continue; + endif + tst_code = ... + ["## DO NOT EDIT!\n", ... + "## Generated automatically from ", tst_file_src{1}, "\n", ... + "## by ", mfilename(), ".m during package installation.\n\n", ... + tst_code]; + [fid, output] = fopen (full_tst_file, "w"); + if (fid == -1) + error ("Octave:pkg:extract-tests", ... + "pkg: error writing extracted tests to 'src': %s", output); + endif + fputs (fid, tst_code); + fclose (fid); + endfor + endif + endif endfunction @@ -152,3 +185,18 @@ endif endfunction + +function body = __extract_test_code__ (nm) + ## Collect all BIST lines starting %! from the file named nm + ## and return them as a single \n-delimited string. + fid = fopen (nm, "rt"); + body = ""; + if (fid >= 0) + while (ischar (ln = fgets (fid))) + if (strncmp (ln, "%!", 2)) + body = [body, ln]; + endif + endwhile + fclose (fid); + endif +endfunction
--- a/scripts/pkg/private/install.m Thu Nov 05 07:46:50 2020 -0800 +++ b/scripts/pkg/private/install.m Thu Nov 05 18:08:55 2020 +0100 @@ -422,9 +422,10 @@ m = dir (fullfile (src, "*.m")); oct = dir (fullfile (src, "*.oct")); mex = dir (fullfile (src, "*.mex")); + tst = dir (fullfile (src, "*tst")); filenames = cellfun (@(x) fullfile (src, x), - {m.name, oct.name, mex.name}, + {m.name, oct.name, mex.name, tst.name}, "uniformoutput", false); endif @@ -475,7 +476,9 @@ function dep = is_architecture_dependent (nm) - persistent archdepsuffix = {".oct",".mex",".a",".lib",".so",".so.*",".dll","dylib"}; + + persistent archdepsuffix = {".oct", ".mex", ".a", ".lib", ".so", ... + "tst", ".so.*", ".dll", "dylib"}; dep = false; for i = 1 : length (archdepsuffix)