In the previous post, I described why I’m writing a small Unix shell, which I’m calling wishr, along with a bit of an overview of how I plan to approach the project. I’m excited to get started on the shell, itself, but it’s important to get a new repo set up for success. So, in this post, I’ll go through the initial repository setup I’ve gone with.

If you’d like to look at the specific git commit, here it is! In future changes, I plan to open up PRs and then share links to them instead of pushing changes directly to the main branch, but as the first substantive commit, I decided to be a little more cavalier on this one.

Application Setup Link to heading

Because this is a Rust project, I started out with cargo new wishr to create the repo. From this, we have a basic Cargo.toml, Cargo.lock, and src/main.rs. Aside from changing "Hello, world" to "Hello, wishr", I haven’t made any code changes. There will be plenty of time to work on the application in the future! 😄

Integration Test Setup Link to heading

Ultimately, I want wishr to be able to successfully pass all of the tests provided by the OSTEP authors. We’ll get to various implementation ideas throughout the project, but I’m considering these tests to be acceptance criteria for the project. In this way, the tests will help me follow a form of Behavior-Driven Development for the project. We will try and make each test pass, one at a time, until every requirement is met.

With that said, I felt like it made sense to keep these tests in the same repository that the code will go into. I created a directory, tester, and then copied the testing code from OSTEP into the directory. I made some minor changes to test-wish.sh (naming it test-wishr.sh in the process), just to make the paths match up correctly. All of the test scenarios remain intact.

Note that when the tests run, results are put into the tester/tests-out directory. I don’t want this checked into source control, so I’ve ignored that subdirectory in tester/.gitignore.

Makefile & Running Integration Tests Link to heading

There are a few targets in Makefile: build, clean, and test-integration. I anticipate additional targets being added over time (unit tests, for example). Of the initial targets, test-integration is the primary one for now. It will clean up any previous build and test artifacts, build the application, and then run the integration tests described previously. I wanted to avoid changing all of the tests that were provided by the OSTEP project, and so the test-integration target copies the wishr binary to the tester directory and renames it to wish. I may end up deciding to change this in the future, but for now, it doesn’t seem that important to me what the executable file is called.

With all of the above in place, we can run our tests (at least until the first one fails!):

>  make test-integration
cargo clean
rm -rf ./tester/tests-out
rm -rf ./tester/wish
cargo build
   Compiling wishr v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.44s
# Copy to `wish` to avoid changing all of the tests; it's not super important what the file is called.
cp ./target/debug/wishr ./tester/wish
cd ./tester && ./test-wishr.sh
test 1: 1.out incorrect
  what results should be found in file: tests/1.out
  what results produced by your program: tests-out/1.out
  compare the two using diff, cmp, or related tools to debug, e.g.:
  prompt> diff tests/1.out tests-out/1.out
  See tests/1.run for what is being run
make: *** [test-integration] Error 1

It looks like our program that prints out “Hello, wishr!” doesn’t pass all of the tests. Bummer! 😄

Vagrant Link to heading

The last big piece of this commit is a Vagrantfile. Vagrant allows us to quickly and consistently spin up virtual machines. I am developing on a Mac, but I’d like to have a Linux machine to test with, and the short Vagrantfile in the commit will allow me to run one with vagrant up.

The machine is based on the latest (currently) version of Ubuntu, Mantic Minotaur. It will install common software build tooling along with the Rust toolchain while it comes up. Once the Vagrant machine is running, I can vagrant ssh into it, move to the /vagrant directory, and then test wishr within Linux.

Conclusion Link to heading

I’m sure I’ll come back and revisit many of these initial pieces over time. However, with that, I think the repo is in a good spot to begin development!