mirror of https://github.com/google/benchmark.git
properly escape json names (#652)
This commit is contained in:
parent
94c4d6d5c6
commit
af441fc114
|
@ -78,7 +78,12 @@ bool JSONReporter::ReportContext(const Context& context) {
|
|||
out << indent << FormatKV("date", walltime_value) << ",\n";
|
||||
|
||||
if (Context::executable_name) {
|
||||
out << indent << FormatKV("executable", Context::executable_name) << ",\n";
|
||||
// windows uses backslash for its path separator,
|
||||
// which must be escaped in JSON otherwise it blows up conforming JSON
|
||||
// decoders
|
||||
std::string executable_name = Context::executable_name;
|
||||
ReplaceAll(&executable_name, "\\", "\\\\");
|
||||
out << indent << FormatKV("executable", executable_name) << ",\n";
|
||||
}
|
||||
|
||||
CPUInfo const& info = context.cpu_info;
|
||||
|
|
|
@ -23,7 +23,8 @@ static int AddContextCases() {
|
|||
{{"^\\{", MR_Default},
|
||||
{"\"context\":", MR_Next},
|
||||
{"\"date\": \"", MR_Next},
|
||||
{"\"executable\": \".*/reporter_output_test(\\.exe)?\",", MR_Next},
|
||||
{"\"executable\": \".*(/|\\\\)reporter_output_test(\\.exe)?\",",
|
||||
MR_Next},
|
||||
{"\"num_cpus\": %int,$", MR_Next},
|
||||
{"\"mhz_per_cpu\": %float,$", MR_Next},
|
||||
{"\"cpu_scaling_enabled\": ", MR_Next},
|
||||
|
|
Loading…
Reference in New Issue