Sample Programs Repo Now Supports Testing

Sample Programs Repo Now Supports Testing Featured Image

With just over a year into the Sample Programs project, we now support testing! For a project that features over 2,300 commits, 250 code snippets, 120 stars, 100 languages, 80 forks, and 60 contributors, it’s about time.

Table of Contents

Credit Where Credit Is Due

In case it’s your first time hearing about the Sample Programs project, let me explain. Sample Programs is a collection of code snippets in as many languages as possible. Currently, we support 106 languages, and we’re excited to watch that number grow.

Being able to test code from such a variety of languages and projects is an amazing feat, but I have to be honest: I didn’t come up with the idea or even implement it. All the credit goes to Parker Johansen (@Auroq) who is our resident polyglot and Docker expert.

In an incredibly short amount of time, Parker put together a testing framework which we can easily augment and extend every time a new project or language comes along. All I did was tie the framework into our continuous integration, so new snippets are tested whenever they arrive.

We’re now able to ensure future code snippets are valid without having to test them by hand like I was doing. Go ahead, give the new framework a test.

Current Support

At the time of writing this article (March 29th), we released support for ten languages including:

  • Bash
  • C++
  • Go
  • Java
  • JavaScript
  • Julia
  • Haskell
  • Perl
  • Python
  • Ruby

In addition, the framework could comfortably support over 10 projects including:

Each project features several tests which can be found in the official project documentation.

I expect this framework to expand rapidly as I find testing and automation enjoyable. I’ll definitely be looking for ways to expand our capabilities.

Future Work

If this project sounds interesting, there are now several ways to help out:

  • Documentation
  • Languages
  • Projects
  • Testing

From a documentation point of view, we need people to start writing articles which explain how each code snippet works. You’re welcome to write your own articles or edit existing ones. Also, for all you web devs out there, we’d love for someone to come along and improve the documentation site.

In terms of languages, we’re always looking to expand our collection. At the time of writing, there were 106 languages represented in the repo. Feel free to check out the wiki to see what we have.

Likewise, we’re always looking for ways to expand our project collection. At the time of writing, we had support for 22 projects which include various sorting algorithms and other fun challenges like prime number detection and factorial calculation. You’re welcome to browse the list of projects to see where you could make some additions.

Finally, we’d love to expand our testing capabilities (as mentioned already). I won’t dig into the specifics too much more, but you’re welcome to browse our issues to see if there’s anything else you could help with.

In the future, I plan to put together an article explaining how the testing system works, so look out for that. In the meantime, why not let me know how it sounds in the comments. If you know anyone who would enjoy this project, let them know by sharing this article with them. Word of mouth is a great way to grow a project like this, and we appreciate the help.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.