Make bisect playable and validate commit_in_future using Git author timestamps

This commit is contained in:
Joe Tretter
2026-05-18 19:44:23 -05:00
parent f5bd5f5a60
commit afb548d46f
10 changed files with 256 additions and 36 deletions

View File

@@ -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() }

View File

@@ -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}")
}
}
}