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 languagesOpens in a new tab. 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 wikiOpens in a new tab. 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 projectsOpens in a new tab. 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 issuesOpens in a new tab. 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.

Sample Programs Repo News (12 Articles)—Series Navigation

Everyone once in awhile, I like to update y’all on what’s going on in the Sample Programs repo. At this point, I’ve written quite a few updates, so I figured it might be helpful to group them as a series.

Jeremy Grifski

Jeremy grew up in a small town where he enjoyed playing soccer and video games, practicing taekwondo, and trading Pokémon cards. Once out of the nest, he pursued a Bachelors in Computer Engineering with a minor in Game Design. After college, he spent about two years writing software for a major engineering company. Then, he earned a master's in Computer Science and Engineering. Today, he pursues a PhD in Engineering Education in order to ultimately land a teaching gig. In his spare time, Jeremy enjoys spending time with his wife, playing Overwatch and Phantasy Star Online 2, practicing trombone, watching Penguins hockey, and traveling the world.

Recent Posts