Skip to content

Script IDE 1.21.0

Choose a tag to compare

@nigelgwork nigelgwork released this 07 Sep 05:34
· 20 commits to main since this release

A test framework: decorators, assertions, mocks, and a namespace per run.

The first of four groups of ideas taken from Ectobox's Script IDE. What is
portable from their runner is the shape of a test framework, not its mechanism —
and their mocking mechanism is not safe on a gateway.

The measurement it rests on

__import__ of a project-library module hands back the manager's own module
object
. Measured on 8.3.8: the same id() from two separate runs, a module
global set in one run read back by the next, and system living in each module's
own globals. So swapping globals()['system'] — how their mocks work — would
change what every other user's scripts see for as long as the block is open.

The runner is therefore handed each selected module's source and executes it
into a namespace private to the run. A mock is then safe, module state no
longer carries between runs
, and where the source cannot be read the runner
imports instead and a mock refuses rather than quietly writing into the shared
copy.

Added

  • @test, @skip, @timeout, @cases, @beforeAll / @afterAll /
    @beforeEach / @afterEach. setUp and tearDown still work.
  • Twelve assertions, including assertRaises, assertAlmostEquals,
    assertTagValue and assertDbRowCount.
  • mockTags and mockQuery — answer tag reads from a dict and queries by SQL
    fragment, record every write and call, and raise for anything they were not
    given.
  • A fourth outcome, skip, and re-run failed only.

See docs/TEST-FRAMEWORK.md.

Two limits, stated rather than left to be discovered

A mock reaches the test module only — production code the test calls still
reaches the real gateway. And scriptide exists only during a run, so a test
module that imports it at the top is not importable outside one. Both are
asserted.

@timeout is a budget, not an interrupt: the test finishes and then fails if
it took too long.

Gate PASS. Java 530, Vitest 689, fifteen live suites 371/371.

Internal module — not on the public portal.