Search in sources :

Example 1 with BlazeVersionInfo

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;
}
Also used : BlazeVersionInfo(com.google.devtools.build.lib.analysis.BlazeVersionInfo) NoBuildEvent(com.google.devtools.build.lib.analysis.NoBuildEvent)

Example 2 with BlazeVersionInfo

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());
}
Also used : BlazeVersionInfo(com.google.devtools.build.lib.analysis.BlazeVersionInfo) Test(org.junit.Test)

Example 3 with BlazeVersionInfo

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());
}
Also used : BlazeVersionInfo(com.google.devtools.build.lib.analysis.BlazeVersionInfo) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 4 with BlazeVersionInfo

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());
}
Also used : BlazeVersionInfo(com.google.devtools.build.lib.analysis.BlazeVersionInfo) Test(org.junit.Test)

Example 5 with BlazeVersionInfo

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());
}
Also used : BlazeVersionInfo(com.google.devtools.build.lib.analysis.BlazeVersionInfo) Test(org.junit.Test)

Aggregations

BlazeVersionInfo (com.google.devtools.build.lib.analysis.BlazeVersionInfo)5 Test (org.junit.Test)4 NoBuildEvent (com.google.devtools.build.lib.analysis.NoBuildEvent)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1