-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
base/tests/utils/integration/com/google/idea/blaze/base/ExternalWorkspaceFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.google.idea.blaze.base; | ||
|
||
import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile; | ||
import com.google.idea.blaze.base.model.BlazeProjectData; | ||
import com.google.idea.blaze.base.model.primitives.ExternalWorkspace; | ||
import com.google.idea.blaze.base.model.primitives.WorkspacePath; | ||
import com.google.idea.blaze.base.model.primitives.WorkspaceRoot; | ||
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager; | ||
import com.intellij.psi.PsiFile; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static com.google.idea.blaze.base.settings.ui.ProjectViewUi.getProject; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class ExternalWorkspaceFixture { | ||
public final ExternalWorkspace workspace; | ||
|
||
final TestFileSystem fileSystem; | ||
WorkspaceFileSystem workspaceFileSystem; | ||
|
||
public ExternalWorkspaceFixture(ExternalWorkspace workspace, TestFileSystem fileSystem) { | ||
this.workspace = workspace; | ||
this.fileSystem = fileSystem; | ||
} | ||
|
||
public WorkspaceRoot getWorkspaceRoot() { | ||
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData(); | ||
assertThat(blazeProjectData).isNotNull(); | ||
|
||
File outputBase = blazeProjectData.getBlazeInfo().getOutputBase(); | ||
|
||
Path workspaceRootPath = Paths.get( | ||
blazeProjectData.getBlazeInfo().getOutputBase().getAbsolutePath(), | ||
"external", workspace.name()); | ||
|
||
return new WorkspaceRoot(workspaceRootPath.normalize().toFile()); | ||
} | ||
|
||
public BuildFile createBuildFile(WorkspacePath workspacePath, String... contentLines) { | ||
PsiFile file = getWorkspaceFileSystem().createPsiFile(workspacePath, contentLines); | ||
assertThat(file).isInstanceOf(BuildFile.class); | ||
return (BuildFile) file; | ||
} | ||
|
||
WorkspaceFileSystem getWorkspaceFileSystem() { | ||
if (workspaceFileSystem == null) { | ||
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData(); | ||
assertNotNull(blazeProjectData); | ||
|
||
File outputBase = blazeProjectData.getBlazeInfo().getOutputBase(); | ||
|
||
|
||
WorkspaceRoot workspaceRoot = new WorkspaceRoot(Paths.get( | ||
blazeProjectData.getBlazeInfo().getOutputBase().getAbsolutePath(), | ||
"external", workspace.name()).normalize().toFile()); | ||
|
||
File workspaceRootFile = workspaceRoot.directory(); | ||
assertThat(workspaceRootFile).isNotNull(); | ||
workspaceFileSystem = new WorkspaceFileSystem(workspaceRoot, fileSystem); | ||
} | ||
|
||
return workspaceFileSystem; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters