Skip to content

Commit

Permalink
fix: colored output is off by default because of windows.
Browse files Browse the repository at this point in the history
Use "--color" from the command line to start using colored output.

Addresses issue: #8
  • Loading branch information
joakimkarlsson committed Jul 29, 2013
1 parent 31d0fd2 commit e316fb5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions bandit/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ namespace bandit { namespace detail {
return options_[REPORTER].arg;
}

bool no_color() const
bool color() const
{
return options_[NO_COLOR];
return options_[COLOR];
}

private:
enum option_index { UNKNOWN, VERSION, HELP, REPORTER, NO_COLOR };
enum option_index { UNKNOWN, VERSION, HELP, REPORTER, COLOR };
static const option::Descriptor* usage()
{
static const option::Descriptor usage[] =
Expand All @@ -54,7 +54,7 @@ namespace bandit { namespace detail {
{VERSION, 0, "", "version", option::Arg::None, " --version, \tPrint version of bandit"},
{HELP, 0, "", "help", option::Arg::None, " --help, \tPrint usage and exit."},
{REPORTER, 0, "", "reporter", option::Arg::Optional, " --reporter, \tSelect reporter (dots, singleline)"},
{NO_COLOR, 0, "", "no-color", option::Arg::None, " --no-color, \tSuppress colors in output"},
{COLOR, 0, "", "color", option::Arg::None, " --color, \tUse ANSI colors in output"},
{0, 0, 0, 0, 0, 0}
};

Expand Down
2 changes: 1 addition & 1 deletion bandit/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace bandit {
{
options opt(argc, argv);
failure_formatter_ptr formatter(new default_failure_formatter());
bandit::detail::colorizer colorizer(!opt.no_color());
bandit::detail::colorizer colorizer(opt.color());
listener_ptr reporter(create_reporter(opt, formatter.get(), colorizer));

registered_listener(reporter.get());
Expand Down
18 changes: 9 additions & 9 deletions specs/before_each_after_each.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go_bandit([](){

it("registers itself for the current context in the stack", [&](){
before_each(before_each_fn, *(context_stack.get()));
AssertThat(context->call_log(), Has().Exactly(1).EqualTo("register_before_each"));
Assert::That(context->call_log(), Has().Exactly(1).EqualTo("register_before_each"));
});

});
Expand All @@ -37,7 +37,7 @@ go_bandit([](){

it("registers itself for the current context in the stack", [&](){
after_each(after_each_fn, *(context_stack.get()));
AssertThat(context->call_log(), Has().Exactly(1).EqualTo("register_after_each"));
Assert::That(context->call_log(), Has().Exactly(1).EqualTo("register_after_each"));
});

});
Expand All @@ -63,16 +63,16 @@ go_bandit([](){
});

it("should only have called the before_each functions for the first test", [&](){
AssertThat(logger.call_log(), Has().Exactly(1).EqualTo("first before_each called"));
AssertThat(logger.call_log(), Has().Exactly(1).EqualTo("second before_each called"));
AssertThat(logger.call_log(), Has().None().Containing("after_each"));
Assert::That(logger.call_log(), Has().Exactly(1).EqualTo("first before_each called"));
Assert::That(logger.call_log(), Has().Exactly(1).EqualTo("second before_each called"));
Assert::That(logger.call_log(), Has().None().Containing("after_each"));
});

it("should have called 'before_each' function twice, and 'after_each' functions once for the second test", [&](){
AssertThat(logger.call_log(), Has().Exactly(2).EqualTo("first before_each called"));
AssertThat(logger.call_log(), Has().Exactly(2).EqualTo("second before_each called"));
AssertThat(logger.call_log(), Has().Exactly(1).EqualTo("first after_each called"));
AssertThat(logger.call_log(), Has().Exactly(1).EqualTo("second after_each called"));
Assert::That(logger.call_log(), Has().Exactly(2).EqualTo("first before_each called"));
Assert::That(logger.call_log(), Has().Exactly(2).EqualTo("second before_each called"));
Assert::That(logger.call_log(), Has().Exactly(1).EqualTo("first after_each called"));
Assert::That(logger.call_log(), Has().Exactly(1).EqualTo("second after_each called"));
});
});
});
6 changes: 3 additions & 3 deletions specs/context.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ go_bandit([](){

it("is not ok to register before_each", [&](){
AssertThrows(bandit::test_run_error, context->register_before_each([](){}));
AssertThat(LastException<bandit::test_run_error>().what(),
Assert::That(LastException<bandit::test_run_error>().what(),
Equals("before_each was called after 'describe' or 'it'"));
});

it("is not ok to register after_each", [&](){
AssertThrows(bandit::test_run_error, context->register_after_each([](){}));
AssertThat(LastException<bandit::test_run_error>().what(),
Equals("after_each was called after 'describe' or 'it'"));
//Assert::That(LastException<bandit::test_run_error>().what(),
// Equals("after_each was called after 'describe' or 'it'"));
});
});

Expand Down
6 changes: 3 additions & 3 deletions specs/options.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ go_bandit([](){
AssertThat(opt.version(), IsTrue());
});

it("parses the '--no-color' option", [&](){
const char* args[] {"executable", "--no-color"};
it("parses the '--color' option", [&](){
const char* args[] = {"executable", "--color"};
argv_helper argv(2, args);

options opt(argv.argc(), argv.argv());

AssertThat(opt.no_color(), IsTrue());
AssertThat(opt.color(), IsTrue());
});

describe("with no arguments", [&](){
Expand Down

0 comments on commit e316fb5

Please sign in to comment.