我想automate git bisect
(说明也可在 official Linux Kernel Git documenation for git bisect
获得)用于使用 MSBuild 构建 .NET 项目,并使用 nunit-console.exe
对其运行单元测试.然而,这些工具是为在 Windows 开发环境中使用而构建的,我在让它们在 msysgit 的 Bash 环境中工作时遇到了各种问题,总结如下:
- Bash 似乎找不到
MSBuild.exe
或nunit-console.exe
(路径问题)。 MSBuild.exe
和nunit-console.exe
都使用 Windows 风格的命令行选项标志,即它们以正斜杠开头,例如MSBuild.exe/M
。在 Bash 中,正斜杠会导致错误,因为正斜杠是 Unix/Linux/*nix 系统用来表示目录路径的。
这是我一直在使用的 git bisect
命令:
$ git bisect start <bad commit> <good commit>
$ git bisect run auto-build-run-tests.sh
这些是 auto-build-run-tests.sh
的内容:
#!/bin/sh
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
# Build solution.
echo "Building..."
MSBuild.exe \
/consoleloggerparameters:ErrorsOnly \
/maxcpucount \
/nologo \
/property:Configuration=Debug \
/verbosity:quiet \
"Epic-Project-of-Supreme-Awesome.sln"
# Check exit status.
# (status != 0) ?
status=$?
if [ $status -ne 0 ]
then
echo "Build failure, status $status."
exit $status
fi
echo "Build success."
# Run unit tests
nunit-console.exe \
/noresult \
/stoponerror \
"bin/Debug/ArtificialIntelligence.Tests.dll" \
"bin/Debug/TravelingSalesManSolver.Tests.dll"
status=$?
if [ $status -ne 0 ]
then
echo "Test failure, status $status."
exit $status
fi
echo "Tests passed."
最佳答案
为了解决路径问题,我干脆在脚本中使用了绝对路径。为了解决 Windows 风格的正斜杠命令行选项问题,我用另一个正斜杠转义了正斜杠(我从另一个 Stack Overflow 答案中得到了这个提示,当我再次找到它时我会链接到它)。
现在工作脚本看起来像这样:
#!/bin/sh
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
# Build solution.
echo "Building..."
c:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe \
//consoleloggerparameters:ErrorsOnly \
//maxcpucount \
//nologo \
//property:Configuration=Debug \
//verbosity:quiet \
Epic-Project-of-Supreme-Awesome.sln
# Check exit status.
# (status != 0) ?
status=$?
if [ $status -ne 0 ]
then
echo "Build failure, status $status."
exit $status
fi
echo "Build success."
# Run unit tests
nunit-console.exe \
//noresult \
//stoponerror \
bin/Debug/ArtificialIntelligence.Tests.dll \
bin/Debug/TravelingSalesManSolver.Tests.dll
status=$?
if [ $status -ne 0 ]
then
echo "Test failure, status $status."
exit $status
fi
echo "Tests passed."
再一次,你像这样运行它:
$ git bisect start <bad commit> <good commit>
$ git bisect run auto-build-run-tests.sh
关于git - 在 msysgit 中为 MSBuild/NUnit/.NET/Windows 批处理命令自动化 git bisect?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17904199/