Make bisect playable and validate commit_in_future using Git author timestamps
This commit is contained in:
@@ -411,6 +411,24 @@ class GitSandboxEngineTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nativeExecutableShortcutRunsScriptThroughShell() {
|
||||
val git = testGitBinary()
|
||||
assumeTrue(git.exists() && git.canExecute())
|
||||
val root = Files.createTempDirectory("githug-script-shortcut").toFile()
|
||||
try {
|
||||
val runtime = GitRepositoryRuntime(root, git)
|
||||
val level = bisectLevel()
|
||||
val repo = runtime.prepareLevel(level)
|
||||
|
||||
val (_, output) = runtime.execute(level, repo, "./test-balance.sh")
|
||||
|
||||
assertTrue(output.joinToString("\n"), output.any { it.contains("balance broken") })
|
||||
} finally {
|
||||
root.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
private fun testGitBinary(): File {
|
||||
System.getenv("GITHUG_TEST_GIT_BINARY")
|
||||
?.takeIf { it.isNotBlank() }
|
||||
|
||||
@@ -130,6 +130,15 @@ class LevelSolutionsTest {
|
||||
"Starting an interactive rebase without an upstream/range must not solve the reorder level.",
|
||||
reorderExercise.validator(bareInteractiveRebaseRepo, "git rebase -i"),
|
||||
)
|
||||
|
||||
val futureCommitExercise = commitInFutureLevel()
|
||||
val futureCommitRuntime = GitRepositoryRuntime(runtimeRoot, gitBinary)
|
||||
val futureCommitRepo = futureCommitRuntime.prepareLevel(futureCommitExercise)
|
||||
val (currentDateCommitRepo, _) = futureCommitRuntime.execute(futureCommitExercise, futureCommitRepo, "git commit -m \"Current date commit\"")
|
||||
assertFalse(
|
||||
"A normal commit using the current system date must not solve the commit_in_future level.",
|
||||
futureCommitExercise.validator(currentDateCommitRepo, "git commit -m \"Current date commit\""),
|
||||
)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
@@ -213,7 +222,7 @@ class LevelSolutionsTest {
|
||||
appendLine(" <none>")
|
||||
} else {
|
||||
commits.forEach { commit ->
|
||||
appendLine(" ${commit.id} ${commit.message}")
|
||||
appendLine(" ${commit.id} ${commit.authorTimestampSeconds ?: "unknown-time"} ${commit.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user