Skip to content

Commit

Permalink
Forge tester: remove some try/catches
Browse files Browse the repository at this point in the history
  • Loading branch information
apjanke committed Mar 18, 2019
1 parent 5e877f3 commit 7a2b4f3
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 97 deletions.
146 changes: 72 additions & 74 deletions inst/+testify/+internal/ForgePkgInstaller.m
Original file line number Diff line number Diff line change
Expand Up @@ -1012,90 +1012,88 @@ function generate_lookfor_cache (desc)
out.error_message = '';
out.exception = [];

try
## Perform ./configure, make, make install in "src".
if (isfolder (fullfile (packdir, "src")))
src = fullfile (packdir, "src");
octave_bindir = __octave_config_info__ ("bindir");
ver = version ();
ext = __octave_config_info__ ("EXEEXT");
mkoctfile_program = fullfile (octave_bindir, ...
sprintf ("mkoctfile-%s%s", ver, ext));
octave_config_program = fullfile (octave_bindir, ...
sprintf ("octave-config-%s%s", ver, ext));
if (ispc () && ! isunix ())
octave_binary = fullfile (octave_bindir, sprintf ("octave-%s.bat", ver));
else
octave_binary = fullfile (octave_bindir, sprintf ("octave-%s%s", ver, ext));
endif
## Perform ./configure, make, make install in "src".
if (isfolder (fullfile (packdir, "src")))
src = fullfile (packdir, "src");
octave_bindir = __octave_config_info__ ("bindir");
ver = version ();
ext = __octave_config_info__ ("EXEEXT");
mkoctfile_program = fullfile (octave_bindir, ...
sprintf ("mkoctfile-%s%s", ver, ext));
octave_config_program = fullfile (octave_bindir, ...
sprintf ("octave-config-%s%s", ver, ext));
if (ispc () && ! isunix ())
octave_binary = fullfile (octave_bindir, sprintf ("octave-%s.bat", ver));
else
octave_binary = fullfile (octave_bindir, sprintf ("octave-%s%s", ver, ext));
endif

if (! exist (mkoctfile_program, "file"))
__gripe_missing_component__ ("pkg", "mkoctfile");
endif
if (! exist (octave_config_program, "file"))
__gripe_missing_component__ ("pkg", "octave-config");
endif
if (! exist (octave_binary, "file"))
__gripe_missing_component__ ("pkg", "octave");
endif

if (verbose)
mkoctfile_program = [mkoctfile_program " --verbose"];
endif

cenv = {"MKOCTFILE"; mkoctfile_program;
"OCTAVE_CONFIG"; octave_config_program;
"OCTAVE"; octave_binary};
scenv = sprintf ("%s='%s' ", cenv{:});

if (! exist (mkoctfile_program, "file"))
__gripe_missing_component__ ("pkg", "mkoctfile");
## Configure.
if (exist (fullfile (src, "configure"), "file"))
flags = "";
if (isempty (getenv ("CC")))
flags = [flags ' CC="' mkoctfile("-p", "CC") '"'];
endif
if (! exist (octave_config_program, "file"))
__gripe_missing_component__ ("pkg", "octave-config");
if (isempty (getenv ("CXX")))
flags = [flags ' CXX="' mkoctfile("-p", "CXX") '"'];
endif
if (! exist (octave_binary, "file"))
__gripe_missing_component__ ("pkg", "octave");
if (isempty (getenv ("AR")))
flags = [flags ' AR="' mkoctfile("-p", "AR") '"'];
endif

if (verbose)
mkoctfile_program = [mkoctfile_program " --verbose"];
if (isempty (getenv ("RANLIB")))
flags = [flags ' RANLIB="' mkoctfile("-p", "RANLIB") '"'];
endif

cenv = {"MKOCTFILE"; mkoctfile_program;
"OCTAVE_CONFIG"; octave_config_program;
"OCTAVE"; octave_binary};
scenv = sprintf ("%s='%s' ", cenv{:});

## Configure.
if (exist (fullfile (src, "configure"), "file"))
flags = "";
if (isempty (getenv ("CC")))
flags = [flags ' CC="' mkoctfile("-p", "CC") '"'];
endif
if (isempty (getenv ("CXX")))
flags = [flags ' CXX="' mkoctfile("-p", "CXX") '"'];
endif
if (isempty (getenv ("AR")))
flags = [flags ' AR="' mkoctfile("-p", "AR") '"'];
endif
if (isempty (getenv ("RANLIB")))
flags = [flags ' RANLIB="' mkoctfile("-p", "RANLIB") '"'];
endif
cmd = ["cd '" src "'; " scenv "./configure " flags];
[status, output] = shell (cmd, verbose);
spew (fullfile (log_dir, 'configure.log'), output);
if (status != 0)
rmdir (desc.dir, "s");
disp (output);
error ("pkg: error running the configure script for %s.", desc.name);
endif
cmd = ["cd '" src "'; " scenv "./configure " flags];
[status, output] = shell (cmd, verbose);
spew (fullfile (log_dir, 'configure.log'), output);
if (status != 0)
rmdir (desc.dir, "s");
disp (output);
out = struct ("success", false, "exception", [], ...
"error_message", sprintf("pkg: error running the configure script for %s.", desc.name));
return
endif
endif

## Make.
if (ispc ())
jobs = 1;
else
jobs = nproc ("overridable");
endif
## Make.
if (ispc ())
jobs = 1;
else
jobs = nproc ("overridable");
endif

if (exist (fullfile (src, "Makefile"), "file"))
[status, output] = shell (sprintf ("%s make --jobs %i --directory '%s'",
scenv, jobs, src), verbose);
spew (fullfile (log_dir, 'make.log'), output);
if (status != 0)
rmdir (desc.dir, "s");
disp (output);
error ("pkg: error running `make' for the %s package.", desc.name);
endif
if (exist (fullfile (src, "Makefile"), "file"))
[status, output] = shell (sprintf ("%s make --jobs %i --directory '%s'",
scenv, jobs, src), verbose);
spew (fullfile (log_dir, 'make.log'), output);
if (status != 0)
rmdir (desc.dir, "s");
disp (output);
out = struct ("success", false, "exception", [], ...
"error_message", sprintf("pkg: error running `make' for the %s package.", desc.name));
return
endif
endif
catch err
out.success = false;
out.error_message = err.message;
out.exception = err;
end_try_catch
endif
endfunction

## Executes a shell command.
Expand Down
42 changes: 19 additions & 23 deletions inst/+testify/+internal/ForgePkgTester.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,18 @@ function install_and_test_forge_pkgs (this)
endfunction

function install_dependency (this, pkg_name)
try
t0 = tic;
say ("Installing dependency: %s", pkg_name);
this.pkgtool.pkg ("install", "-forge", pkg_name);
te = toc (t0);
say ("Package installed (dependency): %s. Elapsed time: %.1f s", pkg_name, te);
this.deps_installed_ok{end+1} = pkg_name;
catch err
t0 = tic;
say ("Installing dependency: %s", pkg_name);
installer = testify.internal.ForgePkgInstaller;
rslt = installer.install (pkg_name);
if ! rslt.success
say ("Package install failure (dependency): %s: %s\n", pkg_name, err.message);
this.dep_install_failures{end+1} = pkg_name;
end_try_catch
return
endif
te = toc (t0);
say ("Package installed (dependency): %s. Elapsed time: %.1f s", pkg_name, te);
this.deps_installed_ok{end+1} = pkg_name;
endfunction

function install_and_test_forge_pkg (this, pkg_name)
Expand Down Expand Up @@ -264,21 +265,16 @@ function install_and_test_forge_pkg (this, pkg_name)
flush_diary
installer = testify.internal.ForgePkgInstaller;
t0 = tic;
try
rslt = installer.install (pkg_name);
te = toc (t0);
this.capture_build_logs (pkg_name, rslt);
if ! rslt.success
error ("Package installation failed: %s. Error: %s", ...
pkg_name, rslt.error_message);
endif
say ("Package installed: %s. Elapsed time: %.1f s", pkg_name, te);
catch err
say ("Error while installing package %s: %s", ...
pkg_name, err.message);
rslt = installer.install (pkg_name);
te = toc (t0);
this.capture_build_logs (pkg_name, rslt);
if ! rslt.success
error ("Package installation failed: %s. Error: %s", ...
pkg_name, rslt.error_message);
this.install_failures{end+1} = pkg_name;
return;
end_try_catch
return
endif
say ("Package installed: %s. Elapsed time: %.1f s", pkg_name, te);
if ismember (pkg_name, this.known_bad_pkgs_test)
say ("Skipping test of known-bad package %s", pkg_name);
this.skipped_pkgs_test{end+1} = pkg_name;
Expand Down

0 comments on commit 7a2b4f3

Please sign in to comment.