ctx.orig_args = Args::from_string("cc -c foo.c -fsyntax-only");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string() == "-fsyntax-only");
- CHECK(result.compiler_args.to_string() == "cc -fsyntax-only -c");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string() == "-fsyntax-only");
+ CHECK(result->compiler_args.to_string() == "cc -fsyntax-only -c");
}
TEST_CASE("dash_E_should_result_in_called_for_preprocessing")
ctx.orig_args = Args::from_string("cc -c foo.c -E");
util::write_file("foo.c", "");
- CHECK(process_args(ctx).error == Statistic::called_for_preprocessing);
+ CHECK(process_args(ctx).error() == Statistic::called_for_preprocessing);
}
TEST_CASE("dash_M_should_be_unsupported")
ctx.orig_args = Args::from_string("cc -c foo.c -M");
util::write_file("foo.c", "");
- CHECK(process_args(ctx).error == Statistic::unsupported_compiler_option);
+ CHECK(process_args(ctx).error() == Statistic::unsupported_compiler_option);
}
TEST_CASE("dependency_args_to_preprocessor_if_run_second_cpp_is_false")
util::write_file("foo.c", "");
ctx.config.set_run_second_cpp(false);
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc " + dep_args);
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "cc -c");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc " + dep_args);
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "cc -c");
}
TEST_CASE("dependency_args_to_compiler_if_run_second_cpp_is_true")
ctx.orig_args = Args::from_string("cc " + dep_args + " -c foo.c -o foo.o");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string() == dep_args);
- CHECK(result.compiler_args.to_string() == "cc -c " + dep_args);
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string() == dep_args);
+ CHECK(result->compiler_args.to_string() == "cc -c " + dep_args);
}
TEST_CASE("cpp_only_args_to_preprocessor_if_run_second_cpp_is_false")
util::write_file("foo.c", "");
ctx.config.set_run_second_cpp(false);
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string()
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string()
== "cc " + cpp_args + " " + dep_args);
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "cc -c");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "cc -c");
}
TEST_CASE(
Args::from_string("cc " + cpp_args + " " + dep_args + " -c foo.c -o foo.o");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc " + cpp_args);
- CHECK(result.extra_args_to_hash.to_string() == dep_args);
- CHECK(result.compiler_args.to_string()
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc " + cpp_args);
+ CHECK(result->extra_args_to_hash.to_string() == dep_args);
+ CHECK(result->compiler_args.to_string()
== "cc " + cpp_args + " -c " + dep_args);
}
ctx.orig_args = Args::from_string("cc -c " + dep_args + " foo.c -o foo.o");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string() == dep_args);
- CHECK(result.compiler_args.to_string() == "cc -c " + dep_args);
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string() == dep_args);
+ CHECK(result->compiler_args.to_string() == "cc -c " + dep_args);
}
TEST_CASE("MQ_flag_should_not_be_added_if_run_second_cpp_is_true")
ctx.orig_args = Args::from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string() == "-MD -MF foo.d");
- CHECK(result.compiler_args.to_string() == "cc -c -MD -MF foo.d");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MD -MF foo.d");
+ CHECK(result->compiler_args.to_string() == "cc -c -MD -MF foo.d");
}
TEST_CASE("MQ_flag_should_be_added_if_run_second_cpp_is_false")
util::write_file("foo.c", "");
ctx.config.set_run_second_cpp(false);
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "cc -c");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "cc -c");
}
TEST_CASE("MF_should_be_added_if_run_second_cpp_is_false")
util::write_file("foo.c", "");
ctx.config.set_run_second_cpp(false);
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "cc -c");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "cc -c");
}
TEST_CASE("MF_should_not_be_added_if_run_second_cpp_is_true")
ctx.orig_args = Args::from_string("cc -c -MD foo.c -o foo.o");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string() == "-MD");
- CHECK(result.compiler_args.to_string() == "cc -c -MD");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MD");
+ CHECK(result->compiler_args.to_string() == "cc -c -MD");
}
TEST_CASE("equal_sign_after_MF_should_be_removed")
ctx.orig_args = Args::from_string("cc -c -MF=path foo.c -o foo.o");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string() == "-MFpath");
- CHECK(result.compiler_args.to_string() == "cc -c -MFpath");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MFpath");
+ CHECK(result->compiler_args.to_string() == "cc -c -MFpath");
}
TEST_CASE("sysroot_should_be_rewritten_if_basedir_is_used")
FMT("cc --sysroot={}/foo/bar -c foo.c", ctx.actual_cwd);
ctx.orig_args = Args::from_string(arg_string);
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
+ const auto result = process_args(ctx);
+ CHECK(result);
#ifdef _WIN32
- CHECK(result.preprocessor_args[1] == "--sysroot=foo\\bar");
+ CHECK(result->preprocessor_args[1] == "--sysroot=foo\\bar");
#else
- CHECK(result.preprocessor_args[1] == "--sysroot=foo/bar");
+ CHECK(result->preprocessor_args[1] == "--sysroot=foo/bar");
#endif
}
std::string arg_string = FMT("cc --sysroot {}/foo -c foo.c", ctx.actual_cwd);
ctx.orig_args = Args::from_string(arg_string);
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args[1] == "--sysroot");
- CHECK(result.preprocessor_args[2] == "foo");
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args[1] == "--sysroot");
+ CHECK(result->preprocessor_args[2] == "foo");
}
TEST_CASE("MF_flag_with_immediate_argument_should_work_as_last_argument")
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string() == "-MMD -MT bar -MFfoo.d");
- CHECK(result.compiler_args.to_string() == "cc -c -MMD -MT bar -MFfoo.d");
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MMD -MT bar -MFfoo.d");
+ CHECK(result->compiler_args.to_string() == "cc -c -MMD -MT bar -MFfoo.d");
}
TEST_CASE("MT_flag_with_immediate_argument_should_work_as_last_argument")
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string()
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string()
== "-MMD -MFfoo.d -MT foo -MTbar");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cc -c -MMD -MFfoo.d -MT foo -MTbar");
}
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc");
- CHECK(result.extra_args_to_hash.to_string()
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc");
+ CHECK(result->extra_args_to_hash.to_string()
== "-MMD -MFfoo.d -MQ foo -MQbar");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cc -c -MMD -MFfoo.d -MQ foo -MQbar");
}
ctx.orig_args = Args::from_string("gcc -c -MD -MP -MFfoo.d -MQ foo.d foo.c");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "gcc");
- CHECK(result.extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MQ foo.d");
- CHECK(result.compiler_args.to_string()
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "gcc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MQ foo.d");
+ CHECK(result->compiler_args.to_string()
== "gcc -c -MD -MP -MFfoo.d -MQ foo.d");
}
ctx.orig_args = Args::from_string("gcc -c -MD -MP -MFfoo.d -MT foo.d foo.c");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "gcc");
- CHECK(result.extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MT foo.d");
- CHECK(result.compiler_args.to_string()
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "gcc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MT foo.d");
+ CHECK(result->compiler_args.to_string()
== "gcc -c -MD -MP -MFfoo.d -MT foo.d");
}
ctx.orig_args = Args::from_string("gcc -c -MD -MP -MFfoo.d -MQfoo.d foo.c");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "gcc");
- CHECK(result.extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MQfoo.d");
- CHECK(result.compiler_args.to_string() == "gcc -c -MD -MP -MFfoo.d -MQfoo.d");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "gcc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MQfoo.d");
+ CHECK(result->compiler_args.to_string()
+ == "gcc -c -MD -MP -MFfoo.d -MQfoo.d");
}
TEST_CASE("MT_flag_with_immediate_argument_should_not_add_MQobj")
ctx.orig_args = Args::from_string("gcc -c -MD -MP -MFfoo.d -MTfoo.d foo.c");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "gcc");
- CHECK(result.extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MTfoo.d");
- CHECK(result.compiler_args.to_string() == "gcc -c -MD -MP -MFfoo.d -MTfoo.d");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "gcc");
+ CHECK(result->extra_args_to_hash.to_string() == "-MD -MP -MFfoo.d -MTfoo.d");
+ CHECK(result->compiler_args.to_string()
+ == "gcc -c -MD -MP -MFfoo.d -MTfoo.d");
}
TEST_CASE(
std::string arg_string = FMT("cc -isystem {}/foo -c foo.c", ctx.actual_cwd);
ctx.orig_args = Args::from_string(arg_string);
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args[2] == "foo");
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args[2] == "foo");
}
#ifndef _WIN32
std::string arg_string = FMT("cc -isystem{}/foo -c foo.c", cwd);
ctx.orig_args = Args::from_string(arg_string);
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args[1] == "-isystemfoo");
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args[1] == "-isystemfoo");
}
TEST_CASE("I_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used")
std::string arg_string = FMT("cc -I{}/foo -c foo.c", cwd);
ctx.orig_args = Args::from_string(arg_string);
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args[1] == "-Ifoo");
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args[1] == "-Ifoo");
}
#endif // _WIN32
ctx.orig_args = Args::from_string("cc -g1 -gsplit-dwarf foo.c -c");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc -g1 -gsplit-dwarf");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "cc -g1 -gsplit-dwarf -c");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc -g1 -gsplit-dwarf");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "cc -g1 -gsplit-dwarf -c");
}
TEST_CASE("debug_flag_order_with_known_option_last")
ctx.orig_args = Args::from_string("cc -gsplit-dwarf -g1 foo.c -c");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc -gsplit-dwarf -g1");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "cc -gsplit-dwarf -g1 -c");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc -gsplit-dwarf -g1");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "cc -gsplit-dwarf -g1 -c");
}
TEST_CASE("options_not_to_be_passed_to_the_preprocessor")
"cc -Wa,foo foo.c -g -c -DX -Werror -Xlinker fie -Xlinker,fum -Wno-error");
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cc -g -DX");
- CHECK(result.extra_args_to_hash.to_string()
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cc -g -DX");
+ CHECK(result->extra_args_to_hash.to_string()
== "-Wa,foo -Werror -Xlinker fie -Xlinker,fum -Wno-error");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cc -g -Wa,foo -Werror -Xlinker fie -Xlinker,fum -Wno-error -DX -c");
}
util::write_file("foo.optf", "-c foo.c -g -Wall -o");
util::write_file("bar.optf", "out -DX");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "nvcc -g -Wall -DX");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "nvcc -g -Wall -DX -c");
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "nvcc -g -Wall -DX");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "nvcc -g -Wall -DX -c");
}
TEST_CASE("nvcc_warning_flags_short")
ctx.orig_args =
Args::from_string("nvcc -Werror all-warnings -Xcompiler -Werror -c foo.cu");
util::write_file("foo.cu", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "nvcc -Xcompiler -Werror");
- CHECK(result.extra_args_to_hash.to_string() == "-Werror all-warnings");
- CHECK(result.compiler_args.to_string()
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "nvcc -Xcompiler -Werror");
+ CHECK(result->extra_args_to_hash.to_string() == "-Werror all-warnings");
+ CHECK(result->compiler_args.to_string()
== "nvcc -Werror all-warnings -Xcompiler -Werror -c");
}
ctx.orig_args = Args::from_string(
"nvcc --Werror all-warnings -Xcompiler -Werror -c foo.cu");
util::write_file("foo.cu", "");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "nvcc -Xcompiler -Werror");
- CHECK(result.extra_args_to_hash.to_string() == "--Werror all-warnings");
- CHECK(result.compiler_args.to_string()
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "nvcc -Xcompiler -Werror");
+ CHECK(result->extra_args_to_hash.to_string() == "--Werror all-warnings");
+ CHECK(result->compiler_args.to_string()
== "nvcc --Werror all-warnings -Xcompiler -Werror -c");
}
+ extra_args + " " + pch_pth_variants);
util::write_file("foo.c", "");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.preprocessor_args.to_string()
+ const auto result = process_args(ctx);
+ CHECK(result->preprocessor_args.to_string()
== "clang " + common_args + " " + pch_pth_variants);
- CHECK(result.extra_args_to_hash.to_string() == extra_args);
- CHECK(result.compiler_args.to_string()
+ CHECK(result->extra_args_to_hash.to_string() == extra_args);
+ CHECK(result->compiler_args.to_string()
== "clang " + common_args + " " + color_diag + " " + extra_args + " "
+ pch_pth_variants + " -c -fcolor-diagnostics");
}
// specification.
ctx.orig_args = Args::from_string("gcc -c foo.c -xCODE");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.preprocessor_args.to_string() == "gcc -xCODE");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "gcc -xCODE -c");
+ const auto result = process_args(ctx);
+ CHECK(result->preprocessor_args.to_string() == "gcc -xCODE");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "gcc -xCODE -c");
}
SUBCASE("compile .c as c++ (without space)")
{
ctx.orig_args = Args::from_string("gcc -xc++ -c foo.c");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
CHECK(ctx.args_info.actual_language == "c++");
- CHECK(result.preprocessor_args.to_string() == "gcc -x c++");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "gcc -x c++ -c");
+ CHECK(result->preprocessor_args.to_string() == "gcc -x c++");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "gcc -x c++ -c");
}
SUBCASE("compile .c as c++ (with space)")
{
ctx.orig_args = Args::from_string("gcc -x c++ -c foo.c");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
CHECK(ctx.args_info.actual_language == "c++");
- CHECK(result.preprocessor_args.to_string() == "gcc -x c++");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "gcc -x c++ -c");
+ CHECK(result->preprocessor_args.to_string() == "gcc -x c++");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "gcc -x c++ -c");
}
SUBCASE("compile .c as c++ (file first, no effect)")
{
ctx.orig_args = Args::from_string("gcc -c foo.c -x c++");
- const ProcessArgsResult result = process_args(ctx);
+ const auto result = process_args(ctx);
CHECK(ctx.args_info.actual_language == "c");
- CHECK(result.preprocessor_args.to_string() == "gcc");
- CHECK(result.extra_args_to_hash.to_string() == "");
- CHECK(result.compiler_args.to_string() == "gcc -c");
+ CHECK(result->preprocessor_args.to_string() == "gcc");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string() == "gcc -c");
}
SUBCASE("unknown -x option (lowercase)")
{
ctx.orig_args = Args::from_string("gcc -x unsupported_language -c foo.c");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::unsupported_source_language);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::unsupported_source_language);
CHECK(ctx.args_info.actual_language == "");
}
SUBCASE("UNKNOWN -x option (uppercase)")
{
ctx.orig_args = Args::from_string("gcc -x UNSUPPORTED_LANGUAGE -c foo.c");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::unsupported_source_language);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::unsupported_source_language);
CHECK(ctx.args_info.actual_language == "");
}
SUBCASE("missing param")
{
ctx.orig_args = Args::from_string("gcc -c foo.c -x");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::bad_compiler_arguments);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::bad_compiler_arguments);
CHECK(ctx.args_info.actual_language == "");
}
}
ctx.orig_args = Args::from_string(
FMT("cl.exe /Fobar.obj /c {}/foo.c /foobar", ctx.actual_cwd));
- const ProcessArgsResult result = process_args(ctx);
- CHECK(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cl.exe /foobar");
- CHECK(result.compiler_args.to_string() == "cl.exe /foobar -c");
+ const auto result = process_args(ctx);
+ CHECK(result);
+ CHECK(result->preprocessor_args.to_string() == "cl.exe /foobar");
+ CHECK(result->compiler_args.to_string() == "cl.exe /foobar -c");
}
TEST_CASE("MSVC PCH options")
{
ctx.orig_args = Args::from_string(
"cl.exe /Ycpch.h /Fppch.cpp.pch /FIpch.h /Fopch.cpp.obj /c pch.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.cpp.pch");
CHECK(ctx.args_info.output_obj == "pch.cpp.obj");
- CHECK(result.preprocessor_args.to_string()
+ CHECK(result->preprocessor_args.to_string()
== "cl.exe /Ycpch.h /Fppch.cpp.pch /FIpch.h");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cl.exe /Ycpch.h /Fppch.cpp.pch /FIpch.h -c");
}
{
ctx.orig_args = Args::from_string(
"cl.exe /Yupch.h /Fppch.cpp.pch /FIpch.h /Fofoo.cpp.obj /c foo.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(!ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.cpp.pch");
CHECK(ctx.args_info.output_obj == "foo.cpp.obj");
- CHECK(result.preprocessor_args.to_string()
+ CHECK(result->preprocessor_args.to_string()
== "cl.exe /Yupch.h /Fppch.cpp.pch /FIpch.h");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cl.exe /Yupch.h /Fppch.cpp.pch /FIpch.h -c");
}
}
{
ctx.orig_args = Args::from_string(
"cl.exe /Yc /Fppch.cpp.pch /FIpch.h /Fopch.cpp.obj /c pch.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.cpp.pch");
CHECK(ctx.args_info.output_obj == "pch.cpp.obj");
- CHECK(result.preprocessor_args.to_string()
+ CHECK(result->preprocessor_args.to_string()
== "cl.exe /Yc /Fppch.cpp.pch /FIpch.h");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cl.exe /Yc /Fppch.cpp.pch /FIpch.h -c");
}
{
ctx.orig_args = Args::from_string(
"cl.exe /Yupch.h /Fppch.cpp.pch /FIpch.h /Fofoo.cpp.obj /c foo.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(!ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.cpp.pch");
CHECK(ctx.args_info.output_obj == "foo.cpp.obj");
- CHECK(result.preprocessor_args.to_string()
+ CHECK(result->preprocessor_args.to_string()
== "cl.exe /Yupch.h /Fppch.cpp.pch /FIpch.h");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cl.exe /Yupch.h /Fppch.cpp.pch /FIpch.h -c");
}
}
SUBCASE("Create PCH")
{
ctx.orig_args = Args::from_string("cl.exe /Yc /Fopch.cpp.obj /c pch.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.pch");
CHECK(ctx.args_info.output_obj == "pch.cpp.obj");
- CHECK(result.preprocessor_args.to_string() == "cl.exe /Yc");
- CHECK(result.compiler_args.to_string() == "cl.exe /Yc -c");
+ CHECK(result->preprocessor_args.to_string() == "cl.exe /Yc");
+ CHECK(result->compiler_args.to_string() == "cl.exe /Yc -c");
}
util::write_file("pch.pch", "");
{
ctx.orig_args = Args::from_string(
"cl.exe /Yupch.h /Fppch.pch /FIpch.h /Fofoo.cpp.obj /c foo.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(!ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.pch");
CHECK(ctx.args_info.output_obj == "foo.cpp.obj");
- CHECK(result.preprocessor_args.to_string()
+ CHECK(result->preprocessor_args.to_string()
== "cl.exe /Yupch.h /Fppch.pch /FIpch.h");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cl.exe /Yupch.h /Fppch.pch /FIpch.h -c");
}
}
SUBCASE("Create PCH")
{
ctx.orig_args = Args::from_string("cl.exe /Yc /c pch.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.pch");
CHECK(ctx.args_info.output_obj == "pch.obj");
- CHECK(result.preprocessor_args.to_string() == "cl.exe /Yc");
- CHECK(result.compiler_args.to_string() == "cl.exe /Yc -c");
+ CHECK(result->preprocessor_args.to_string() == "cl.exe /Yc");
+ CHECK(result->compiler_args.to_string() == "cl.exe /Yc -c");
}
util::write_file("pch.pch", "");
{
ctx.orig_args = Args::from_string(
"cl.exe /Yupch.h /Fppch.pch /FIpch.h /Fofoo.cpp.obj /c foo.cpp");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
+ const auto result = process_args(ctx);
+ REQUIRE(result);
CHECK(!ctx.args_info.generating_pch);
CHECK(ctx.args_info.included_pch_file == "pch.pch");
CHECK(ctx.args_info.output_obj == "foo.cpp.obj");
- CHECK(result.preprocessor_args.to_string()
+ CHECK(result->preprocessor_args.to_string()
== "cl.exe /Yupch.h /Fppch.pch /FIpch.h");
- CHECK(result.compiler_args.to_string()
+ CHECK(result->compiler_args.to_string()
== "cl.exe /Yupch.h /Fppch.pch /FIpch.h -c");
}
}
{
ctx.orig_args =
Args::from_string("cl.exe /Yc /FpE:\\foo\\bar\\ /c pch.cpp");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::could_not_use_precompiled_header);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::could_not_use_precompiled_header);
CHECK(ctx.args_info.generating_pch);
CHECK(ctx.args_info.orig_included_pch_file == "E:\\foo\\bar\\");
CHECK(ctx.args_info.output_obj == "pch.obj");
SUBCASE("/Fp with relative folder path")
{
ctx.orig_args = Args::from_string("cl.exe /Yc /Fpfolder\\ /c pch.cpp");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::could_not_use_precompiled_header);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::could_not_use_precompiled_header);
CHECK(ctx.args_info.generating_pch);
CHECK(ctx.args_info.orig_included_pch_file == "folder\\");
CHECK(ctx.args_info.output_obj == "pch.obj");
SUBCASE("Only /Z7")
{
ctx.orig_args = Args::from_string("cl.exe /c foo.c /Z7");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cl.exe /Z7");
- CHECK(result.compiler_args.to_string() == "cl.exe /Z7 -c");
+ const auto result = process_args(ctx);
+ REQUIRE(result);
+ CHECK(result->preprocessor_args.to_string() == "cl.exe /Z7");
+ CHECK(result->compiler_args.to_string() == "cl.exe /Z7 -c");
}
SUBCASE("Only /Zi")
{
ctx.orig_args = Args::from_string("cl.exe /c foo.c /Zi");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::unsupported_compiler_option);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::unsupported_compiler_option);
}
SUBCASE("Only /ZI")
{
ctx.orig_args = Args::from_string("cl.exe /c foo.c /ZI");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::unsupported_compiler_option);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::unsupported_compiler_option);
}
SUBCASE("/Z7 + /Zi")
{
ctx.orig_args = Args::from_string("cl.exe /Z7 /c foo.c /Zi");
- const ProcessArgsResult result = process_args(ctx);
- CHECK(result.error == Statistic::unsupported_compiler_option);
+ const auto result = process_args(ctx);
+ CHECK(result.error() == Statistic::unsupported_compiler_option);
}
SUBCASE("/Zi + /Z7")
{
ctx.orig_args = Args::from_string("cl.exe /Zi /c foo.c /Z7");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
- CHECK(result.preprocessor_args.to_string() == "cl.exe /Zi /Z7");
- CHECK(result.compiler_args.to_string() == "cl.exe /Zi /Z7 -c");
+ const auto result = process_args(ctx);
+ REQUIRE(result);
+ CHECK(result->preprocessor_args.to_string() == "cl.exe /Zi /Z7");
+ CHECK(result->compiler_args.to_string() == "cl.exe /Zi /Z7 -c");
}
}
SUBCASE("/Z7")
{
ctx.orig_args = Args::from_string("clang-cl.exe /c foo.c /Z7");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
- CHECK(result.preprocessor_args.to_string() == "clang-cl.exe /Z7");
+ const auto result = process_args(ctx);
+ REQUIRE(result);
+ CHECK(result->preprocessor_args.to_string() == "clang-cl.exe /Z7");
}
SUBCASE("/Zi")
{
ctx.orig_args = Args::from_string("clang-cl.exe /c foo.c /Zi");
- const ProcessArgsResult result = process_args(ctx);
- REQUIRE(!result.error);
- CHECK(result.preprocessor_args.to_string() == "clang-cl.exe /Zi");
+ const auto result = process_args(ctx);
+ REQUIRE(result);
+ CHECK(result->preprocessor_args.to_string() == "clang-cl.exe /Zi");
}
}