Skip to content

About

Toplo backend for Spec (Pharo)

Topics

Resources

Stars

6 stars

Watchers

8 watching

Forks

Latest commit

 

History

515 Commits

Folders and files

Repository files navigation

Spec-Toplo

License Tests

Toplo backend for Spec.

Toplo is a widget library on top of Bloc.

Spec is a Pharo library for describing user interfaces. You describe a UI by composing the "presenters" and by connecting them via block closures.

More concretely, a Spec UI is a tree of SpPresenter, that is opened in the context of an application (SpApplication) that, among others, indicates what is the backend.

Our backend (SpToploBackend) provides the adapters (hierarchy of SpToploAdapter) to make the Toplo widgets to act as the tree of presenters describe.

Other Spec backends are:

  • Morphic (the default)
  • GTK

Install

The project can be loaded as usual via Metacello, using the BaselineOfSpecToplo specification. To copy/paste a loading script, see this wiki page.

Running Tests

When developing Spec-Toplo, you should run two sets of test suites:

  1. Toplo-specific backend tests: Packages matching Spec-Toplo*-Tests (Spec-Toplo-Tests, Spec-Toplo-Backend-Tests), which test Toplo adapters, widgets, and synchronization directly.
  2. Spec2 generic contract tests: Package Spec2-Backend-Tests (SpButtonAdapterTest, SpLabelAdapterTest, SpBoxLayoutAdapterTest, etc.). These verify that SpToploBackend conforms to the upstream Spec2 contract.
"Run both suites in DrTests or via Smalltalk script:"
(TestRunner runPackages: {
	'Spec-Toplo-Tests'.
	'Spec-Toplo-Backend-Tests'.
	'Spec2-Backend-Tests' })

Configuring Host Backends (Headless vs Interactive)

Generic Spec tests are parameterized by Bloc host. By default, they run exclusively on the fast Headless host to avoid stealing focus or opening OS windows during development.

You can toggle whether tests run headless-only or across all available hosts (Headless, SDL3, SDL2, Morphic) in two ways:

1. Via System Settings UI

Open Settings Browser (World Menu > System > Settings), navigate to:

Bloc > Hosts for parameterized tests
  • Headless host only (Fast) (Default): Runs tests headlessly in background.
  • All available hosts: Tests the matrix against all registered hosts (including real OS windows).
ParameterizedTests

2. Programmatically

"Run fast on headless host only (default)"
BlParameterizedHostTest testHostsMode: #headlessOnly.

"Run full matrix across Headless, SDL2, and Morphic"
BlParameterizedHostTest testHostsMode: #allAvailable.

Debugging

Running with Toplo vs. Morphic

To run or debug a presenter with the Toplo backend, assign an application configured with #Toplo:

app := StPharoApplication new.
app useBackend: #Toplo.

presenter := MyPresenter new.
presenter application: app.
presenter open.

Tip: Omitting presenter application: app opens the presenter with the default Morphic backend, enabling side-by-side visual and behavioral comparisons.

Navigating Adapters, Widgets, and Constraints

When diagnosing layout, event, or styling issues, navigate between Spec presenters and Toplo widgets:

"Retrieve the Toplo adapter from the presenter"
adapter := presenter adapter. "Answers an SpToplo*Adapter"

"Retrieve the root BlElement / To* widget"
widget := presenter adapter widget.

"Inspect layout constraint resizers vs. actual computed geometry bounds"
widget constraints horizontal resizer. "e.g. Match parent, Exact 200, Fit content"
widget bounds asRectangle.

To quickly close temporary spaces opened during interactive debugging in the Playground, evaluate Bloc closeSpaces.

Bloc Foundation Documentation

For the underlying Bloc concurrency model, testing, and layout mechanics, refer to the documentation in the Bloc repository:

Continuous Integration

GitHub Actions runs on every push and pull request. The workflows are in .github/workflows:

  • ci.yml loads the project in a new image and runs the minimal tests (.ci.ston) on Pharo 14 and Pharo 15.
  • full-tests.yml runs the broader test set (.SpecBackendTests.ston) on the same Pharo versions. Some of these tests still fail, which is why they run separately.

Each run packages the image it tested, so you can download it and debug locally. The package contains:

  • Spec-Toplo-Pharo14.image (or Pharo15) and its .changes file
  • the .sources file of Pharo
  • pharo.version, which contains 140 for Pharo 14 and 150 for Pharo 15

There are three kinds of artefacts:

  • Action artefacts are saved on every run, including when the tests fail. Open the run from the Actions tab, then download Spec-Toplo-Pharo14 or Spec-Toplo-Pharo15 from its Artifacts section. GitHub keeps them for a limited time.
  • Continuous artefacts are published on every push to dev. They are attached to the continuous pre-release on the Releases page, as Spec-Toplo-Pharo14.zip and Spec-Toplo-Pharo15.zip. Each push replaces the previous ones. The pre-release is published even when the tests fail, so check the CI run for the test results.
  • Release artefacts are attached to every GitHub release when you create or edit it. The release job runs only when the build succeeds, so failing builds are not attached to releases.

To debug a downloaded image, unzip the package, then open the .image file with the Pharo VM of the matching version.

Branches & Contributions

We describe our contribution workflow & branch name convention in this wiki page.

License

This code is licensed under the MIT license.

About

Toplo backend for Spec (Pharo)

Topics

Resources

Stars

6 stars

Watchers

8 watching

Forks

Releases

Used by

Contributors

Languages