June 28th, 2014

Seeing colors with psake

Heath Stewart
Principal Software Engineer

Psake (pronounced like Japanese “sake”) is a build automation tool similar to others out there like make, rake, etc., but built using PowerShell as the language of choice. So it should be no surprise that I use it for my Windows Installer PowerShell Module. It’s useful for automating tasks not limited to just calling MSBuild, but also my PowerShell Help compiler (which loads the module in a separate process, thus allowing me to keep building in the same PowerShell host process), and selected tests with MSTest.

When tests fail (and when practicing TDD they often do), it can be hard to identify which tests failed. Not only are my test names long because of the root namespace, but also because all the test results are the same color. This is were psake can really shimmer. With the changes highlighted in commit 079b56f I can wrap the results to shorten the names and add a bit of flare:

Screenshot

The colors were chosen to mimic test results in Visual Studio’s Test Explorer which I normally use for feature-level work. This makes it easy to identify failed tests. Implemented similar to the Exec function in psake, $LASTEXITCODE is set correctly to also work with tasks like git bisect run for finding when a particular test might have been broken (though normally I run all unit tests before committing). The only real disadvantage is having to wait for MSTest to finish before seeing output but, at least for this project, the selected tests don’t take long enough for that to be a problem.

Hopefully you find this little script tip helpful. What sort of customizations do you like to make to your build environment?

Author

Heath Stewart
Principal Software Engineer

Heath is an application architect and developer, looking to help educate others to learn professional development. Besides designing and developing applications he enjoys writing about intermediate and advanced topics. Heath also consults for deployment packages and scenarios within Microsoft and for external customers.

0 comments

Discussion are closed.