Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed tests failing when run on Windows (#1407)
* Fixed tests failing on Windows due to line ending, path separator, and path ordering differences * Removed test-util dependency from sqldelight-gradle-plugin * Reverted accidental change to dependencies for sqldelight-gradle-plugin
- Loading branch information
Showing
10 changed files
with
64 additions
and
15 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
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
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
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
37 changes: 37 additions & 0 deletions
37
sqldelight-gradle-plugin/src/test/kotlin/com/squareup/sqldelight/TestUtil.kt
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,37 @@ | ||
package com.squareup.sqldelight | ||
|
||
import com.squareup.sqldelight.core.SqlDelightCompilationUnit | ||
import com.squareup.sqldelight.core.SqlDelightDatabaseProperties | ||
import com.squareup.sqldelight.core.SqlDelightPropertiesFile | ||
import com.squareup.sqldelight.core.SqlDelightSourceFolder | ||
|
||
internal fun String.withInvariantPathSeparators() = replace("\\", "/") | ||
|
||
internal fun SqlDelightPropertiesFile.withInvariantPathSeparators(): SqlDelightPropertiesFile { | ||
return SqlDelightPropertiesFile( | ||
databases = databases.map { it.withInvariantPathSeparators() } | ||
) | ||
} | ||
|
||
internal fun SqlDelightDatabaseProperties.withInvariantPathSeparators(): SqlDelightDatabaseProperties { | ||
return copy( | ||
compilationUnits = compilationUnits.map { it.withInvariantPathSeparators() }, | ||
outputDirectory = outputDirectory.withInvariantPathSeparators() | ||
) | ||
} | ||
|
||
internal fun SqlDelightDatabaseProperties.withSortedCompilationUnits(): SqlDelightDatabaseProperties { | ||
return copy( | ||
compilationUnits = compilationUnits.map { it.withSortedSourceFolders() } | ||
) | ||
} | ||
|
||
private fun SqlDelightCompilationUnit.withInvariantPathSeparators(): SqlDelightCompilationUnit { | ||
return copy(sourceFolders = sourceFolders.map { it.withInvariantPathSeparators() }) | ||
} | ||
|
||
private fun SqlDelightCompilationUnit.withSortedSourceFolders(): SqlDelightCompilationUnit { | ||
return copy(sourceFolders = sourceFolders.sortedBy { it.path }) | ||
} | ||
|
||
private fun SqlDelightSourceFolder.withInvariantPathSeparators() = copy(path = path.withInvariantPathSeparators()) |
5 changes: 5 additions & 0 deletions
5
test-util/src/main/kotlin/com/squareup/sqldelight/test/util/Extensions.kt
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,5 @@ | ||
package com.squareup.sqldelight.test.util | ||
|
||
fun String.withInvariantPathSeparators() = replace("\\", "/") | ||
fun String.withInvariantLineSeparators() = replace("\r\n", "\n") | ||
fun String.splitLines() = split("\\r?\\n".toRegex()) |