CPCWiki forum

General Category => Programming => Topic started by: duncan_bayne on 07:20, 06 July 13

Title: Test driven development on an Amstrad CPC
Post by: duncan_bayne on 07:20, 06 July 13
Hi Folks,

I'm trying to develop a (simple, Scheme-like) Lisp for the Amstrad CPC.  I'm hoping to develop it test-first, and my efforts are working so far.

See: Running tests on an Amstrad CPC on Vimeo (https://vimeo.com/69787152)

All the source is up at duncan-bayne/zlisp ยท GitHub (https://github.com/duncan-bayne/zlisp) if you want to take a look at how I'm doing test driven development on this system. 

Elevator pitch: I have two different build targets.  One provides |REPL to run the Lisp environment (or at least, it will when I'm finished).  The other provides |TESTS to run the automated tests.

If you have any questions, please feel free to ask :)  This has been something of a learning experience for me, trying to follow modern development practices to develop software for an 8-bit micro.

Yours,
Duncan


Title: Re: Test driven development on an Amstrad CPC
Post by: Octoate on 15:35, 07 July 13
Great idea to bring TDD to CPC development. I will have a look at it for sure :)!
Title: Re: Test driven development on an Amstrad CPC
Post by: duncan_bayne on 00:46, 09 July 13
Quote from: Octoate on 15:35, 07 July 13
Great idea to bring TDD to CPC development. I will have a look at it for sure :) !

Thanks :)

The rough approach I'm taking is to have two separate targets in the Makefile.  The default is the usual release build, and then there's another that compiles the tests including a main.c that runs them all.  Then, fire up the emulator and run |TESTS.  Here's an example test, checking that my changes to the SDCC heap size worked:

#include "lisp_tests.h"

void _test_heap_size();

void _test_heap_size()
{
  /* SDCC defaults to a 1kB heap size; check we have > 30kB to play with */
  void *block = malloc(30720);
  assert(block != NULL);
  free(block);
}

void run_lisp_tests()
{
  RUN_TEST(_test_heap_size);
}


RUN_TEST is a macro defined elsewhere:

#define RUN_TEST(a) printf("%s:%d ... ", __FILE__, __LINE__); a(); printf("OK\r\n");

It works well so far but I'm concerned about running out of resources with a complex program and a large test suite.
Powered by SMFPacks Menu Editor Mod