Skip to content

Commit

Permalink
Merge pull request #2057 from bjaglin/flaky
Browse files Browse the repository at this point in the history
Fix flaky integration tests
bjaglin authored Aug 26, 2024
2 parents e179fe4 + 05bc781 commit a93135d
Showing 4 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -241,7 +241,7 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
)

override def withSourceroot(path: Path): ScalafixArguments = {
require(path.isAbsolute, s"sourceroot must be relative: $path")
require(path.isAbsolute, s"sourceroot must be absolute: $path")
copy(args = args.copy(sourceroot = Some(AbsolutePath(path)(args.cwd))))
}

Original file line number Diff line number Diff line change
@@ -161,7 +161,6 @@ trait BaseCliSuite extends AnyFunSuite with DiffAssertions {
preprocess: AbsolutePath => Unit = _ => (),
outputAssert: String => Unit = _ => (),
rule: String = "RemoveUnused",
path: RelativePath = removeImportsPath,
files: String = removeImportsPath.toString()
): Unit = {
test(name) {
Original file line number Diff line number Diff line change
@@ -89,7 +89,6 @@ class CliSemanticSuite extends BaseCliSuite {
},
expectedExit = ExitStatus.StaleSemanticdbError,
rule = "RemoveUnused",
path = removeImportsPath,
files = removeImportsPath.toString(),
outputAssert = { out =>
assert(out.contains("Stale SemanticDB"))
@@ -114,7 +113,6 @@ class CliSemanticSuite extends BaseCliSuite {
},
expectedExit = ExitStatus.Ok,
rule = "RemoveUnused",
path = removeImportsPath,
files = removeImportsPath.toString(),
outputAssert = { out =>
assert(out.isEmpty)
@@ -129,16 +127,13 @@ class CliSemanticSuite extends BaseCliSuite {
),
expectedExit = ExitStatus.Ok,
rule = "RemoveUnused",
path = removeImportsPath,
files = removeImportsPath.toString()
)

checkSemantic(
name = "remove unused OK (auto-classpath)",
args = Array(
"--auto-classpath",
"--auto-classpath-roots",
PathIO.workingDirectory.toString
"--auto-classpath"
) ++ Classpaths.scalaLibrary.entries.toArray.flatMap { path =>
Array(
"--auto-classpath-roots",
@@ -147,7 +142,6 @@ class CliSemanticSuite extends BaseCliSuite {
},
expectedExit = ExitStatus.Ok,
rule = "RemoveUnused",
path = removeImportsPath,
files = removeImportsPath.toString()
)

@@ -162,8 +156,7 @@ class CliSemanticSuite extends BaseCliSuite {
),
// Errors in RemoveUnused are suppressed.
expectedExit = ExitStatus.Ok,
rule = "RemoveUnused",
path = removeImportsPath
rule = "RemoveUnused"
)

checkSemantic(
Original file line number Diff line number Diff line change
@@ -40,6 +40,9 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
val scalaLibrary: Seq[AbsolutePath] = Classpaths.scalaLibrary.entries

val rawApi: ScalafixArguments = ScalafixArgumentsImpl()
// instead of the repo root, set a non-empty, stable directory to avoid
// getting errors due to concurrent compilation of other projects
.withWorkingDirectory(Paths.get("scalafix-core/src/main").toAbsolutePath)

// fixturing variant of test, allowing to customize created input files
def fsTest[T](testName: String, testTags: Tag*)(

0 comments on commit a93135d

Please sign in to comment.