Author Topic: Test driven development on an Amstrad CPC  (Read 1724 times)

0 Members and 1 Guest are viewing this topic.

Offline duncan_bayne

  • CPC464
  • **
  • Posts: 49
  • Country: au
    • Duncan Bayne
    • Awards
Test driven development on an Amstrad CPC
« on: 09: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

All the source is up at duncan-bayne/zlisp ยท GitHub 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


like
0
No reactions

Offline Octoate

  • CPC6128
  • ****
  • Posts: 290
  • Country: de
    • Octoate.de
    • Awards
Re: Test driven development on an Amstrad CPC
« Reply #1 on: 17:35, 07 July 13 »
Great idea to bring TDD to CPC development. I will have a look at it for sure :)!
like
0
No reactions
--

Offline duncan_bayne

  • CPC464
  • **
  • Posts: 49
  • Country: au
    • Duncan Bayne
    • Awards
Re: Test driven development on an Amstrad CPC
« Reply #2 on: 02:46, 09 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:

Code: [Select]
#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:

Code: [Select]
#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.
« Last Edit: 02:48, 09 July 13 by duncan_bayne »
like
0
No reactions