Ninja
status_test.cc
Go to the documentation of this file.
1 // Copyright 2011 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "status.h"
16 
17 #include "test.h"
18 
19 TEST(StatusTest, StatusFormatElapsed) {
20  BuildConfig config;
21  StatusPrinter status(config);
22 
23  status.BuildStarted();
24  // Before any task is done, the elapsed time must be zero.
25  EXPECT_EQ("[%/e0.000]", status.FormatProgressStatus("[%%/e%e]", 0));
26  // Before any task is done, the elapsed time must be zero.
27  EXPECT_EQ("[%/e00:00]", status.FormatProgressStatus("[%%/e%w]", 0));
28 }
29 
30 TEST(StatusTest, StatusFormatReplacePlaceholder) {
31  BuildConfig config;
32  StatusPrinter status(config);
33 
34  EXPECT_EQ("[%/s0/t0/r0/u0/f0]",
35  status.FormatProgressStatus("[%%/s%s/t%t/r%r/u%u/f%f]", 0));
36 }
TEST(StatusTest, StatusFormatElapsed)
Definition: status_test.cc:19
Options (e.g. verbosity, parallelism) passed to a build.
Definition: build.h:176
Implementation of the Status interface that prints the status as human-readable strings to stdout.
void BuildStarted() override
std::string FormatProgressStatus(const char *progress_status_format, int64_t time_millis) const
Format the progress status string by replacing the placeholders.