use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildApksCommandTest method outputFileAlreadyExists_throws.
@Test
public void outputFileAlreadyExists_throws() throws Exception {
createAppBundle(bundlePath);
Files.createFile(outputFilePath);
ParsedFlags flags = new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath);
BuildApksCommand command = BuildApksCommand.fromFlags(flags, fakeAdbServer);
Exception e = assertThrows(IllegalArgumentException.class, command::execute);
assertThat(e).hasMessageThat().contains("already exists");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildApksCommandTest method badSdkBundleFileExtension_throws.
@Test
public void badSdkBundleFileExtension_throws() throws Exception {
Path badSdkBundlePath = tmpDir.resolve("sdk_bundle.aab");
createSdkBundle(badSdkBundlePath);
createSdkBundle(sdkBundlePath1);
createAppBundle(bundlePath);
BuildApksCommand command = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--sdk-bundles=" + sdkBundlePath1 + "," + badSdkBundlePath), fakeAdbServer);
Exception e = assertThrows(IllegalArgumentException.class, command::execute);
assertThat(e).hasMessageThat().contains("ASB file 'sdk_bundle.aab' is expected to have '.asb' extension.");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildApksCommandTest method nonPositiveMaxThreads_throws.
@Test
public void nonPositiveMaxThreads_throws() throws Exception {
FlagParseException zeroException = assertThrows(FlagParseException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--max-threads=0"), fakeAdbServer));
assertThat(zeroException).hasMessageThat().contains("flag --max-threads has illegal value");
FlagParseException negativeException = assertThrows(FlagParseException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--max-threads=-1"), fakeAdbServer));
assertThat(negativeException).hasMessageThat().contains("flag --max-threads has illegal value");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildApksCommandTest method buildingViaFlagsAndBuilderHasSameResult_defaults.
@Test
public void buildingViaFlagsAndBuilderHasSameResult_defaults() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
BuildApksCommand commandViaFlags = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH), new PrintStream(output), systemEnvironmentProvider, fakeAdbServer);
BuildApksCommand.Builder commandViaBuilder = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(commandViaFlags.getAapt2Command().get()).setExecutorServiceInternal(commandViaFlags.getExecutorService()).setExecutorServiceCreatedByBundleTool(true).setOutputPrintStream(commandViaFlags.getOutputPrintStream().get());
DebugKeystoreUtils.getDebugSigningConfiguration(systemEnvironmentProvider).ifPresent(commandViaBuilder::setSigningConfiguration);
assertThat(commandViaBuilder.build()).isEqualTo(commandViaFlags);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildApksCommandTest method lineageFlag_noOldestSigner_fails.
@Test
public void lineageFlag_noOldestSigner_fails() {
InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, "--ks=" + keystorePath, "--ks-key-alias=" + KEY_ALIAS, "--ks-pass=pass:" + KEYSTORE_PASSWORD, "--key-pass=pass:" + KEY_PASSWORD, "--lineage=" + tmpDir.resolve("lineage-file")), fakeAdbServer));
assertThat(e).hasMessageThat().isEqualTo("Flag 'oldest-signer' is required when 'lineage' is set.");
}
Aggregations