Automatic cross-platform testing: part 2: FreeBSD
Tags: testing, cirrusci, ci, freebsd
Published: 2020-02-28 23:37:17

---
title: Automatic cross-platform testing: part 2: FreeBSD
published: true
description: How to automatically test on FreeBSD, using Cirrus-CI
tags: Testing, Cirrus-CI, CI, FreeBSD
---

#Previously on this channel

* [Introduction and testing on Linux](https://dev.to/drhyde/automatic-cross-platform-testing-part-1-linux-40ih)

#Testing on FreeBSD

We saw in the previous exciting episode how to automatically test your code on Linux even if you don't have easy access to Linux yourself. Next, we're going to look at doing the same on FreeBSD. This time I used [Cirrus-CI](https://cirrus-ci.com/), again because they were the first reasonable looking service that I found. Just like with Travis, you'll need to start by signing in using your Github account and granting Cirrus-CI some access. You then need to configure it [on Github's website](https://github.com/marketplace/cirrus-ci). Scroll to the bottom of that page, select "Public repositories", and then hit "Install it for free". Jump through a few minor hoops, being careful not to commit to paying anything, and finally you can [add a config file](https://github.com/DrHyde-347624/example-project/blob/master/.cirrus.yml) to your repository.

As with Travis it will notice the new file almost immediately, and start to build. Note that this time you don't have to tell it about each repository individually, it will by default look for its build instructions in any of your repositories.

![Started a build on Cirrus-CI](https://dev-to-uploads.s3.amazonaws.com/i/9kcb7suxeh5co95f5iny.png)

Cirrus's free service is slower than Travis's, as it takes longer to create the virtual machine which will run your code. Sometimes it even fails to provision the VM in a reasonable time and just aborts, because of resource limits in the free service. When that happens you can easily get it to try again through the web interface.

![Two checks are now listed](https://dev-to-uploads.s3.amazonaws.com/i/wntztbxwvnuf7afxiqjw.png)

Wait a little while and - horrors! - the tests have failed.

![My tests failed](https://dev-to-uploads.s3.amazonaws.com/i/fk2tzi3y92h59kldkkdf.png)

This gets us to one of the bits of using these third-party CI systems that can be rather annoying. It can be hard to figure out exactly what's going wrong when you don't have interactive access to the machine in question, and the edit/test/review cycle is slow. My immediate suspicion was that my scripts wanted *bash* but that's a GNUism so might not be installed on FreeBSD. Just [having Cirrus install that](https://github.com/DrHyde-347624/example-project/commit/2dfc18) didn't immediately work, so I had to do a bit of noodling about before tracking down the problem - yes, I did need to install bash, but I also needed to change the `#!` at the top of my scripts because it's installed in `/usr/local/bin` instead of `/bin`. If you want a laugh, you can [watch me flailing around trying to debug that](https://github.com/DrHyde-347624/example-project/compare/linux-passing...freebsd-passing). It's worth noting that for each of those commits, if you click on the angry red crosses signifying an overall failure, that every commit is also being tested by Travis, and you only get a pleasing green tick if both builds pass.

#Next

In [part 3](https://dev.to/drhyde/automatic-cross-platform-testing-part-3-macos-2h2i) we'll add support for testing on MacOS