use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project buck by facebook.
the class OcamlBuildRulesGenerator method generateNativeLinking.
/**
* Links the .cmx files generated by the native compilation
*/
private BuildRule generateNativeLinking(ImmutableList<SourcePath> allInputs) {
BuildRuleParams linkParams = params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(ruleFinder.filterBuildRuleInputs(allInputs)).addAll(ocamlContext.getNativeLinkableInput().getArgs().stream().flatMap(arg -> arg.getDeps(ruleFinder).stream()).iterator()).addAll(ocamlContext.getCLinkableInput().getArgs().stream().flatMap(arg -> arg.getDeps(ruleFinder).stream()).iterator()).addAll(cxxCompiler.getDeps(ruleFinder)).build()), Suppliers.ofInstance(ImmutableSortedSet.of()));
ImmutableList.Builder<Arg> flags = ImmutableList.builder();
flags.addAll(ocamlContext.getFlags());
flags.addAll(StringArg.from(ocamlContext.getCommonCLinkerFlags()));
OcamlLink link = new OcamlLink(linkParams, allInputs, cxxCompiler.getEnvironment(pathResolver), cxxCompiler.getCommandPrefix(pathResolver), ocamlContext.getOcamlCompiler().get(), flags.build(), ocamlContext.getOcamlInteropIncludesDir(), ocamlContext.getNativeOutput(), ocamlContext.getNativePluginOutput(), ocamlContext.getNativeLinkableInput().getArgs(), ocamlContext.getCLinkableInput().getArgs(), ocamlContext.isLibrary(), /* isBytecode */
false, buildNativePlugin);
resolver.addToIndex(link);
return link;
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project buck by facebook.
the class OcamlBuildRulesGenerator method generateBytecodeLinking.
/**
* Links the .cmo files generated by the bytecode compilation
*/
private BuildRule generateBytecodeLinking(ImmutableList<SourcePath> allInputs) {
BuildRuleParams linkParams = params.withBuildTarget(addBytecodeFlavor(params.getBuildTarget())).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(ruleFinder.filterBuildRuleInputs(allInputs)).addAll(ocamlContext.getBytecodeLinkDeps()).addAll(Stream.concat(ocamlContext.getBytecodeLinkableInput().getArgs().stream(), ocamlContext.getCLinkableInput().getArgs().stream()).flatMap(arg -> arg.getDeps(ruleFinder).stream()).filter(rule -> !(rule instanceof OcamlBuild)).iterator()).addAll(cxxCompiler.getDeps(ruleFinder)).build()), Suppliers.ofInstance(ImmutableSortedSet.of()));
ImmutableList.Builder<Arg> flags = ImmutableList.builder();
flags.addAll(ocamlContext.getFlags());
flags.addAll(StringArg.from(ocamlContext.getCommonCLinkerFlags()));
OcamlLink link = new OcamlLink(linkParams, allInputs, cxxCompiler.getEnvironment(pathResolver), cxxCompiler.getCommandPrefix(pathResolver), ocamlContext.getOcamlBytecodeCompiler().get(), flags.build(), ocamlContext.getOcamlInteropIncludesDir(), ocamlContext.getBytecodeOutput(), ocamlContext.getNativePluginOutput(), ocamlContext.getBytecodeLinkableInput().getArgs(), ocamlContext.getCLinkableInput().getArgs(), ocamlContext.isLibrary(), /* isBytecode */
true, /* buildNativePlugin */
false);
resolver.addToIndex(link);
return link;
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project presto by prestodb.
the class TestHivePageSink method writeTestFile.
private static long writeTestFile(HiveClientConfig config, ExtendedHiveMetastore metastore, String outputPath) {
HiveTransactionHandle transaction = new HiveTransactionHandle();
ConnectorPageSink pageSink = createPageSink(transaction, config, metastore, new Path("file:///" + outputPath));
List<LineItemColumn> columns = getTestColumns();
List<Type> columnTypes = columns.stream().map(LineItemColumn::getType).map(TestHivePageSink::getHiveType).map(hiveType -> hiveType.getType(TYPE_MANAGER)).collect(toList());
PageBuilder pageBuilder = new PageBuilder(columnTypes);
int rows = 0;
for (LineItem lineItem : new LineItemGenerator(0.01, 1, 1)) {
rows++;
if (rows >= NUM_ROWS) {
break;
}
pageBuilder.declarePosition();
for (int i = 0; i < columns.size(); i++) {
LineItemColumn column = columns.get(i);
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i);
switch(column.getType().getBase()) {
case IDENTIFIER:
BIGINT.writeLong(blockBuilder, column.getIdentifier(lineItem));
break;
case INTEGER:
INTEGER.writeLong(blockBuilder, column.getInteger(lineItem));
break;
case DATE:
DATE.writeLong(blockBuilder, column.getDate(lineItem));
break;
case DOUBLE:
DOUBLE.writeDouble(blockBuilder, column.getDouble(lineItem));
break;
case VARCHAR:
createUnboundedVarcharType().writeSlice(blockBuilder, Slices.utf8Slice(column.getString(lineItem)));
break;
default:
throw new IllegalArgumentException("Unsupported type " + column.getType());
}
}
}
Page page = pageBuilder.build();
pageSink.appendPage(page);
getFutureValue(pageSink.finish());
File outputDir = new File(outputPath);
List<File> files = ImmutableList.copyOf(outputDir.listFiles((dir, name) -> !name.endsWith(".crc")));
File outputFile = getOnlyElement(files);
long length = outputFile.length();
ConnectorPageSource pageSource = createPageSource(transaction, config, outputFile);
List<Page> pages = new ArrayList<>();
while (!pageSource.isFinished()) {
Page nextPage = pageSource.getNextPage();
if (nextPage != null) {
nextPage.assureLoaded();
pages.add(nextPage);
}
}
MaterializedResult expectedResults = toMaterializedResult(getSession(config), columnTypes, ImmutableList.of(page));
MaterializedResult results = toMaterializedResult(getSession(config), columnTypes, pages);
assertEquals(results, expectedResults);
return length;
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project sonar-java by SonarSource.
the class XmlFileSensorTest method test_no_issues_but_xml_file_still_published.
@Test
public void test_no_issues_but_xml_file_still_published() throws Exception {
SensorContextTester context = SensorContextTester.create(new File("src/test/files/maven2/").getAbsoluteFile());
DefaultFileSystem fs = context.fileSystem();
final File file = new File("src/test/files/maven2/pom.xml");
DefaultInputFile inputFile = new TestInputFileBuilder("", "pom.xml").setModuleBaseDir(fs.baseDirPath()).setPublish(false).build();
fs.add(inputFile);
SonarComponents sonarComponents = createSonarComponentsMock(fs, file);
XmlFileSensor sensor = new XmlFileSensor(sonarComponents, fs);
assertThat(inputFile.isPublished()).isFalse();
sensor.execute(context);
assertThat(inputFile.isPublished()).isTrue();
verify(sonarComponents, never()).reportIssue(Mockito.argThat(argument -> file.getAbsolutePath().equals(argument.getFile().getAbsolutePath())));
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project closure-compiler by google.
the class RefasterJsTestUtils method assertFileRefactoring.
/**
* Performs refactoring using a RefasterJs template and asserts that result is as expected.
*
* @param refasterJsTemplate path of the file or resource containing the RefasterJs template to
* apply
* @param testDataPathPrefix path prefix of the directory from which input and expected-output
* file will be read
* @param originalFile file name of the JavaScript source file to apply the refaster template to
* @param additionalSourceFiles list of additional source files to provide to the compiler (e.g.
* dependencies)
* @param expectedFileChoices the expected result options of applying the specified template to
* {@code originalFile}
* @throws IOException
*/
public static void assertFileRefactoring(String refasterJsTemplate, String testDataPathPrefix, String originalFile, List<String> additionalSourceFiles, String... expectedFileChoices) throws IOException {
RefasterJsScanner scanner = new RefasterJsScanner();
scanner.loadRefasterJsTemplate(refasterJsTemplate);
final String originalFilePath = testDataPathPrefix + File.separator + originalFile;
ImmutableList.Builder<String> expectedCodeBuilder = ImmutableList.builder();
for (String expectedFile : expectedFileChoices) {
expectedCodeBuilder.add(slurpFile(testDataPathPrefix + File.separator + expectedFile));
}
final ImmutableList<String> expectedCode = expectedCodeBuilder.build();
RefactoringDriver.Builder driverBuilder = new RefactoringDriver.Builder().addExterns(CommandLineRunner.getBuiltinExterns(CompilerOptions.Environment.BROWSER));
for (String additionalSource : additionalSourceFiles) {
driverBuilder.addInputsFromFile(testDataPathPrefix + File.separator + additionalSource);
}
RefactoringDriver driver = driverBuilder.addInputsFromFile(originalFilePath).build();
List<SuggestedFix> fixes = driver.drive(scanner);
assertThat(driver.getCompiler().getErrors()).isEmpty();
assertThat(driver.getCompiler().getWarnings()).isEmpty();
ImmutableList<String> newCode = ApplySuggestedFixes.applyAllSuggestedFixChoicesToCode(fixes, ImmutableMap.of(originalFilePath, slurpFile(originalFilePath))).stream().map(m -> m.get(originalFilePath)).collect(ImmutableList.toImmutableList());
assertThat(newCode).comparingElementsUsing(new IgnoringWhitespaceCorrespondence()).containsExactlyElementsIn(expectedCode);
}
Aggregations