XOD 0.26.0: Tabular unit tests

Victor Nakoryakov
Dec 27, 2018 · 4 min read

Hello, folks. The last 2018 release of the XOD visual programming language is here! This is a hacker’s delight release. The most significant enhancements are tabtests and the new CLI. Tab-what?

OK, have you ever heard about automated unit tests in programming? It is a technique for more confident, comfortable, and quick development. A programmer who writes the code also writes a test scenario. Then, an automated framework checks whether the actual results of code execution match expectations of the test scenario. There can be dozens, hundreds, or thousands of tests in a project which would take hours to check manually. Thanks, computers, they can do it for seconds at will.

The new testing framework of XOD is called tabular tests or tabtests for short. The test scenarios are defined as simple Excel-alike tables. For example, we want to test a node which formats a number.

One can define the following test:

    NUM   DIG   STR
1.3272 4 "1.3272"
1.3272 2 "1.33"
1.3272 0 "1"
1.4723 0 "1"
1.5 0 "2"
1.5 -2 "2"
-1.1992 4 "-1.1992"

Now, we can click the “Run” button and a few seconds later, vois-lá:

When a test table is run, behind the scenes, it is compiled in the XOD cloud and then executes in a sandbox. This guarantees that even malicious code which could be potentially included in a third-party library C++ has no change to harm your PC or your privacy.

The tabtest framework allowed us to catch and fix a dozen of bugs in the standard library. This made XOD more robust and reliable.

Test own projects. Learn how to create tests with new articles:

Moreover, the tabular testing framework proves that XOD programs can be compiled for PC as well as for Arduinos. This opens the doors to patch simulation without uploads. We’ll implement it later.

Command line interface

What a development system without a comprehensive CLI? There was always a xodc tool in the XOD ecosystem, but it was somewhat awkward. A major rework has been done, and now it comes with new useful subcommands, sane documentation, and consistency. See README for details.

You might wonder where is the CLI even useful as we have the visual IDE. The answer is automation. If you want to put a XOD project under a continuous integration system, auto-generate patches, perform routine tasks quickly, you’ll find it very handy.

~/devel/xod-workspace
$ xodc install:arch arduino:avr
Downloading arduino:avr-gcc@4.9.2-atmel3.5.4-arduino2... 98%
arduino:avr-gcc@4.9.2-atmel3.5.4-arduino2 downloaded
Downloading arduino:avrdude@6.3.0-arduino9... 0%
arduino:avrdude@6.3.0-arduino9 downloaded
Downloading arduino:arduinoOTA@1.1.1... 54%
arduino:arduinoOTA@1.1.1 downloaded
Downloading arduino:avr@1.6.21... 93%
arduino:avr@1.6.21 downloaded
Installing arduino:avr-gcc@4.9.2-atmel3.5.4-arduino2
arduino:avr-gcc@4.9.2-atmel3.5.4-arduino2 installed
Installing arduino:avrdude@6.3.0-arduino9
arduino:avrdude@6.3.0-arduino9 installed
Installing arduino:arduinoOTA@1.1.1
arduino:arduinoOTA@1.1.1 installed
Installing arduino:avr@1.6.21...
arduino:avr@1.6.21 installedDone!
~/devel/xod-workspace 29s
$ xodc upload --board arduino:avr:nano --port /dev/ttyUSB0 stepper.xodball example
✔ Initialize
✔ Check board
✔ Project loading
✔ Transforming
✔ Transpiling
✔ Uploading
Begin compiling code for the board Arduino Nano
Using board 'nano' from platform in folder: /home/nailxx/xod/__packages__/packages/arduino/hardware/avr/1.6.21
Using core 'arduino' from platform in folder: /home/nailxx/xod/__packages__/packages/arduino/hardware/avr/1.6.21
Detecting libraries used...
Generating function prototypes...
Compiling sketch...
Compiling libraries...
Compiling core...
Linking everything together...
Sketch uses 3922 bytes (12%) of program storage space. Maximum is 30720 bytes.
Global variables use 69 bytes (3%) of dynamic memory, leaving 1979 bytes for local variables. Maximum is 2048 bytes.
Uploading compiled code to the board...
avrdude: AVR device initialized and ready to accept instructionsReading | ################################################## | 100% 0.01savrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "/tmp/xod_temp_sketchbookxRXRkC/xod_1545901044072_sketch/xod_1545901044072_sketch.arduino.avr.nano.hex"
avrdude: writing flash (3922 bytes):
Writing | ################################################## | 100% 1.49savrdude: 3922 bytes of flash written
avrdude: verifying flash memory against
avrdude: load data flash data from input file
avrdude: input file /tmp/xod_temp_sketchbookxRXRkC
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 1.33savrdude: verifying ...
avrdude: 3922 bytes of flash verified
avrdude done. Thank you.Done!

As usual, the release includes many other small improvements and enhancements. Read the full list on GitHub.

Get the new version of XOD from the downloads page or try it directly in your browser. If you have XOD installed already, accept the upgrade offer when IDE starts.

Test everything!

XODlang

XOD visual programming language use cases and projects

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store