use of com.google.devtools.build.lib.analysis.BlazeVersionInfo in project bazel by bazelbuild.
the class VersionCommand method exec.
@Override
public ExitCode exec(CommandEnvironment env, OptionsProvider options) {
BlazeVersionInfo info = BlazeVersionInfo.instance();
if (info.getSummary() == null) {
env.getReporter().handle(Event.error("Version information not available"));
return ExitCode.COMMAND_LINE_ERROR;
}
env.getEventBus().post(new NoBuildEvent());
env.getReporter().getOutErr().printOutLn(info.getSummary());
return ExitCode.SUCCESS;
}
use of com.google.devtools.build.lib.analysis.BlazeVersionInfo in project bazel by bazelbuild.
the class BlazeVersionInfoTest method testEmptyVersionInfoMeansNotAvailable.
@Test
public void testEmptyVersionInfoMeansNotAvailable() {
BlazeVersionInfo info = new BlazeVersionInfo(Collections.<String, String>emptyMap());
assertFalse(info.isAvailable());
assertNull(info.getSummary());
assertEquals("development version", info.getReleaseName());
}
use of com.google.devtools.build.lib.analysis.BlazeVersionInfo in project bazel by bazelbuild.
the class BlazeVersionInfoTest method testFancySummaryFormatting.
@Test
public void testFancySummaryFormatting() {
Map<String, String> data = new HashMap<>();
data.put("Some entry", "foo");
data.put("Another entry", "bar");
data.put("And a third entry", "baz");
BlazeVersionInfo info = new BlazeVersionInfo(data);
Map<String, String> sortedData = new TreeMap<>(data);
assertEquals(StringUtilities.layoutTable(sortedData), info.getSummary());
}
use of com.google.devtools.build.lib.analysis.BlazeVersionInfo in project bazel by bazelbuild.
the class BlazeVersionInfoTest method testReleaseNameIsDevelopmentIfBuildLabelIsNull.
@Test
public void testReleaseNameIsDevelopmentIfBuildLabelIsNull() {
Map<String, String> data = singletonMap("Build label", "");
BlazeVersionInfo info = new BlazeVersionInfo(data);
assertEquals("development version", info.getReleaseName());
}
use of com.google.devtools.build.lib.analysis.BlazeVersionInfo in project bazel by bazelbuild.
the class BlazeVersionInfoTest method testReleaseNameIfBuildLabelIsPresent.
@Test
public void testReleaseNameIfBuildLabelIsPresent() {
Map<String, String> data = singletonMap("Build label", "3/4/2009 (gold)");
BlazeVersionInfo info = new BlazeVersionInfo(data);
assertEquals("release 3/4/2009 (gold)", info.getReleaseName());
}
Aggregations