Skip to content

Commit

Permalink
Add list of failed and skipped targets to tail summary.
Browse files Browse the repository at this point in the history
This expands out the failed and skipped summary tail lines to also include a sorted list of action and targets of the corresponding failed and skipped targets. This makes it easier to see them and to further search for individual ones in teh rest of the output. It also makes it possible to quickly retry specific targets.

fixes #196
  • Loading branch information
grafikrobot committed Mar 6, 2024
1 parent 0538ac4 commit 6c1a655
Show file tree
Hide file tree
Showing 16 changed files with 193 additions and 9 deletions.
3 changes: 3 additions & 0 deletions doc/src/history.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Make C/C++/ObjC include directive scanning pattern more strict to avoid
trying to scan for empty file names.
-- _Andrey Semashev_
* Add listing of failed and skipped targets to end of build summary to make it
easier to find what fails.
-- _René Ferdinand Rivera Morell_

== Version 5.0.1

Expand Down
1 change: 1 addition & 0 deletions src/engine/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ set B2_SOURCES=%B2_SOURCES% mod_regex.cpp
set B2_SOURCES=%B2_SOURCES% mod_sequence.cpp
set B2_SOURCES=%B2_SOURCES% mod_set.cpp
set B2_SOURCES=%B2_SOURCES% mod_string.cpp
set B2_SOURCES=%B2_SOURCES% mod_summary.cpp
set B2_SOURCES=%B2_SOURCES% mod_sysinfo.cpp
set B2_SOURCES=%B2_SOURCES% mod_version.cpp

Expand Down
1 change: 1 addition & 0 deletions src/engine/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ mod_regex.cpp \
mod_sequence.cpp \
mod_set.cpp \
mod_string.cpp \
mod_summary.cpp \
mod_sysinfo.cpp \
mod_version.cpp \
"
Expand Down
44 changes: 37 additions & 7 deletions src/engine/make1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@
#include "output.h"
#include "startup.h"

#include "mod_summary.h"

#include <assert.h>
#include <stdlib.h>
#include <memory>

#if !defined( NT ) || defined( __GNUC__ )
#include <unistd.h> /* for unlink */
Expand All @@ -81,6 +84,10 @@ static struct
int32_t made;
} counts[ 1 ];

static std::unique_ptr<b2::summary> make_summary;
static const char * targets_failed = "targets failed";
static const char * targets_skipped = "targets skipped";

/* Target state. */
#define T_STATE_MAKE1A 0 /* make1a() should be called */
#define T_STATE_MAKE1B 1 /* make1b() should be called */
Expand Down Expand Up @@ -207,6 +214,9 @@ int32_t make1( LIST * targets )
int32_t status = 0;

memset( (char *)counts, 0, sizeof( *counts ) );
make_summary.reset(new b2::summary);
make_summary->group(targets_failed);
make_summary->group(targets_skipped);

{
LISTITER iter, end;
Expand Down Expand Up @@ -247,15 +257,25 @@ int32_t make1( LIST * targets )
clear_state_freelist();

/* Talk about it. */
if ( counts->failed )
out_printf( "...failed updating %d target%s...\n", counts->failed,
counts->failed > 1 ? "s" : "" );
if ( DEBUG_MAKE && counts->skipped )
out_printf( "...skipped %d target%s...\n", counts->skipped,
counts->skipped > 1 ? "s" : "" );
if ( DEBUG_MAKE && counts->made )
out_printf( "...updated %d target%s...\n", counts->made,
{
out_printf( "\n...updated %d target%s...\n", counts->made,
counts->made > 1 ? "s" : "" );
}
if ( DEBUG_MAKE && counts->skipped )
{
out_printf( "\n...skipped %d target%s...\n",
make_summary->count(targets_skipped),
make_summary->count(targets_skipped) > 1 ? "s" : "" );
make_summary->print(targets_skipped, " %s\n");
}
if ( counts->failed )
{
out_printf( "\n...failed updating %d target%s...\n",
make_summary->count(targets_failed),
make_summary->count(targets_failed) > 1 ? "s" : "" );
make_summary->print(targets_failed, " %s\n");
}

/* If we were interrupted, exit now that all child processes
have finished. */
Expand Down Expand Up @@ -425,15 +445,18 @@ static void make1b( state * const pState )
if ( ( t->status == EXEC_CMD_FAIL ) && t->actions )
{
++counts->skipped;
make_summary->message(targets_skipped, object_str( t->name ));
if ( ( t->flags & ( T_FLAG_RMOLD | T_FLAG_NOTFILE ) ) == T_FLAG_RMOLD )
{
if ( !unlink( object_str( t->boundname ) ) )
out_printf( "...removing outdated %s\n", object_str( t->boundname )
);
}
else
{
out_printf( "...skipped %s for lack of %s...\n", object_str( t->name ),
failed_name );
}
}

if ( t->status == EXEC_CMD_OK )
Expand Down Expand Up @@ -941,6 +964,13 @@ static void make1c_closure
out_printf( "...failed %s ", object_str( cmd->rule->name ) );
list_print( lol_get( (LOL *)&cmd->args, 0 ) );
out_printf( "...\n" );
std::string m = object_str( cmd->rule->name );
for (auto i: b2::list_cref(lol_get( (LOL *)&cmd->args, 0 )))
{
m += " ";
m += i->str();
}
make_summary->message(targets_failed, m.c_str());
}

/* On interrupt, set quit so _everything_ fails. Do the same for failed
Expand Down
46 changes: 46 additions & 0 deletions src/engine/mod_summary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright 2024 René Ferdinand Rivera Morell
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
*/

#include "mod_summary.h"

#include "output.h"

#include <memory>

namespace b2 {

void summary::group(value_ref group)
{
group_order.push_back(group);
groups.emplace(group, new std::vector<value_ref>);
}

void summary::message(value_ref group, value_ref message)
{
groups[group]->push_back(message);
}

int summary::count(value_ref group)
{
return (int)(groups[group]->size());
}

void summary::print(value_ref group, value_ref format)
{
std::string format_str = format;
auto & g = groups[group];
std::sort(g->begin(), g->end(), [](value_ref a, value_ref b) -> bool
{
return std::strcmp(a->str(), b->str()) < 0;
});
for (auto const & m : *g)
{
std::string m_str = m;
out_printf(format->str(), m_str.c_str());
}
}

} // namespace b2
59 changes: 59 additions & 0 deletions src/engine/mod_summary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2024 René Ferdinand Rivera Morell
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
*/

#ifndef B2_MOD_SUMMARY_H
#define B2_MOD_SUMMARY_H

#include "config.h"

#include "bind.h"
#include "value.h"

#include <unordered_map>
#include <vector>

namespace b2 {

class summary : public object
{
public:
void group(value_ref group);
void message(value_ref group, value_ref message);
int count(value_ref group);
void print(value_ref group, value_ref format);

private:
using group_t = std::unique_ptr<std::vector<value_ref>>;
using groups_t = std::unordered_map<value_ref,
group_t,
value_ref::hash_function,
value_ref::equal_function>;

groups_t groups;
std::vector<value_ref> group_order;
};

struct summary_module : b2::bind::module_<summary_module>
{
const char * module_name = "summary";

template <class Binder>
void def(Binder & binder)
{
binder.def_class("summary", type_<summary>())
.def(init_<>())
.def(&summary::group, "group", "group" * _1)
.def(&summary::message, "message", "group" * _1,
"message" * _1n)
.def(&summary::count, "count", "group" * _1)
.def(&summary::print, "print", "group" * _1,
"format" * _1);
}
};

} // namespace b2

#endif
2 changes: 2 additions & 0 deletions test/core_actions_quietly.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
[subtest_b] 0
[subtest_b] 1
[subtest_b] 2
...updated 2 targets...
""")

t.run_build_system(["-ffile.jam", "-d1"], stdout="""\
...found 4 targets...
...updating 2 targets...
...updated 2 targets...
""")

Expand Down
5 changes: 4 additions & 1 deletion test/core_jamshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
t.expect_output_lines([
"...failed run test-raw-fail...",
"0,1,2",
"",
"...updated 2 targets...",
"",
"...failed updating 1 target...",
"...updated 2 targets..."])
" run test-raw-fail"])

t.cleanup()
11 changes: 10 additions & 1 deletion test/core_multifile_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
updating x1 x2
update x2
updating x2 x3
...updated 3 targets...
""")

Expand All @@ -59,6 +60,7 @@
updating x1 x2
update x2
updating x2 x3
...updated 3 targets...
""")

Expand Down Expand Up @@ -96,8 +98,11 @@
...failed fail x1...
update x2
updating x2
...failed updating 2 targets...
...updated 1 target...
...failed updating 1 target...
fail x1
""")

# Make sure that dependencies of targets that are
Expand All @@ -124,6 +129,7 @@
updating x2
update x2
updating x2 x3
...updated 3 targets...
""")

Expand All @@ -147,6 +153,7 @@
...updating 2 targets...
update x1
updating x1 x2
...updated 2 targets...
""")

Expand All @@ -164,6 +171,7 @@
...updating 1 target...
update x1
updating x1 x1
...updated 1 target...
""")

Expand Down Expand Up @@ -194,6 +202,7 @@
updating x3 x4 : s4
update x4
updating x4 x3 : s5
...updated 4 targets...
""")

Expand Down
1 change: 1 addition & 0 deletions test/core_option_d2.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
[subtest_b] 0
[subtest_b] 1
[subtest_b] 2
...updated 2 targets...
""")

Expand Down
1 change: 1 addition & 0 deletions test/core_option_n.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
echo [subtest_b] 1
echo [subtest_b] 2
...updated 2 targets...
""")
t.expect_nothing_more()
Expand Down
1 change: 1 addition & 0 deletions test/core_parallel_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
[.b] 0
[.b] 1
[.b] 2
...updated 8 targets...
""")

Expand Down
1 change: 1 addition & 0 deletions test/core_parallel_multifile_actions_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
003
.use.2 u2.user
004
...updated 4 targets...
""")

Expand Down
1 change: 1 addition & 0 deletions test/core_parallel_multifile_actions_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
001 - linked
install installed_dll
002 - installed
...updated 3 targets...
""")

Expand Down
Loading

0 comments on commit 6c1a655

Please sign in to comment.