Search in sources :

Example 1 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project buck by facebook.

the class CxxPreprocessAndCompileIntegrationTest method sanitizeSymlinkedWorkingDirectory.

@Test
public void sanitizeSymlinkedWorkingDirectory() throws IOException {
    TemporaryFolder folder = new TemporaryFolder();
    folder.create();
    ProjectFilesystem filesystem = new ProjectFilesystem(folder.getRoot().toPath());
    // Setup up a symlink to our working directory.
    Path symlinkedRoot = folder.getRoot().toPath().resolve("symlinked-root");
    java.nio.file.Files.createSymbolicLink(symlinkedRoot, tmp.getRoot());
    // Run the build, setting PWD to the above symlink.  Typically, this causes compilers to use
    // the symlinked directory, even though it's not the right project root.
    BuildTarget target = BuildTargetFactory.newInstance("//:simple#default,static");
    workspace.runBuckCommandWithEnvironmentOverridesAndContext(tmp.getRoot(), Optional.empty(), ImmutableMap.of("PWD", symlinkedRoot.toString()), "build", target.getFullyQualifiedName()).assertSuccess();
    // Verify that we still sanitized this path correctly.
    Path lib = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s/libsimple.a"));
    String contents = Files.asByteSource(lib.toFile()).asCharSource(Charsets.ISO_8859_1).read();
    assertFalse(lib.toString(), contents.contains(tmp.getRoot().toString()));
    assertFalse(lib.toString(), contents.contains(symlinkedRoot.toString()));
    folder.delete();
}
Also used : Path(java.nio.file.Path) BuildTarget(com.facebook.buck.model.BuildTarget) TemporaryFolder(org.junit.rules.TemporaryFolder) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project android_frameworks_base by ResurrectionRemix.

the class DiskStatsFileLoggerTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    temporaryFolder = new TemporaryFolder();
    temporaryFolder.create();
    mOutputFile = temporaryFolder.newFile();
    mMainResult = new FileCollector.MeasurementResult();
    mDownloadsResult = new FileCollector.MeasurementResult();
    mPackages = new ArrayList<>();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) Before(org.junit.Before)

Example 3 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project android_frameworks_base by ResurrectionRemix.

the class FileCollectorTest method setUp.

@Before
public void setUp() throws Exception {
    temporaryFolder = new TemporaryFolder();
    temporaryFolder.create();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) Before(org.junit.Before)

Example 4 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project android_frameworks_base by DirtyUnicorns.

the class DiskStatsLoggingServiceTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    MockitoAnnotations.initMocks(this);
    mTemporaryFolder = new TemporaryFolder();
    mTemporaryFolder.create();
    mInputFile = mTemporaryFolder.newFile();
    mDownloads = new TemporaryFolder();
    mDownloads.create();
    mRootDirectory = new TemporaryFolder();
    mRootDirectory.create();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) Before(org.junit.Before)

Example 5 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project android_frameworks_base by DirtyUnicorns.

the class FileCollectorTest method setUp.

@Before
public void setUp() throws Exception {
    temporaryFolder = new TemporaryFolder();
    temporaryFolder.create();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) Before(org.junit.Before)

Aggregations

TemporaryFolder (org.junit.rules.TemporaryFolder)88 File (java.io.File)33 Test (org.junit.Test)25 Before (org.junit.Before)24 BeforeClass (org.junit.BeforeClass)13 Path (java.nio.file.Path)7 URL (java.net.URL)6 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 UserState (alluxio.security.user.UserState)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)2 DocumentMetaData (de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URISyntaxException (java.net.URISyntaxException)2 BdpDataPlanePlugin (org.batfish.bdp.BdpDataPlanePlugin)2 Batfish (org.batfish.main.Batfish)2 DefaultSafeModeManager (alluxio.master.DefaultSafeModeManager)1 InMemoryReferenceSequenceFile (au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile)1 SynchronousReferenceLookupAdapter (au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter)1