Skip to content

Commit

Permalink
Allowing to sprt against different branch
Browse files Browse the repository at this point in the history
  • Loading branch information
tsoj committed May 22, 2024
1 parent 3401a88 commit 9cc126c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/testing/runSprtTest.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ../startPositions, ../positionUtils
import ../startPositions, ../positionUtils, ../utils

import std/[osproc, os, strutils, strformat, json]

Expand All @@ -23,12 +23,20 @@ doAssert "not a git repository" notin gitStatus
let
gitHasUnstagedChanges = execProcess("git status -suno").strip != ""
currentBranch = execProcess("git rev-parse --abbrev-ref HEAD").strip
otherBranch =
if commandLineParams().len >= 1:
commandLineParams()[0].strip
else:
mainBranch

echo "Testing against ", otherBranch

doAssert not gitHasUnstagedChanges, "Shouldn't do SPRT with unstaged changes"

if currentBranch == mainBranch:

if currentBranch == otherBranch:
while true:
stdout.write "You are about to test the main branch against itself. Are you sure you want to do this? [y/n] "
stdout.write "You are about to test a branch against itself. Are you sure you want to do this? [y/n] "
stdout.flushFile
let answer = readLine(stdin).strip.toLowerAscii
if answer == "y":
Expand All @@ -42,7 +50,7 @@ proc moonbirdBinary(branch: string): string =
fmt"{getCurrentDir()}/{workDir}Moonbird-{branch}"

try:
for branch in [mainBranch, currentBranch]:
for branch in [otherBranch, currentBranch]:
discard tryRemoveFile moonbirdBinaryFile
if execCmd("git switch " & branch) != 0:
raise newException(CatchableError, "Failed to switch to branch " & branch)
Expand Down Expand Up @@ -90,8 +98,8 @@ let cuteataxxSettings =
"protocol": "UAI",
},
{
"name": "Moonbird-" & mainBranch,
"path": moonbirdBinary(mainBranch),
"name": "Moonbird-" & otherBranch,
"path": moonbirdBinary(otherBranch),
"protocol": "UAI",
},
],
Expand Down

0 comments on commit 9cc126c

Please sign in to comment.