Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose DSL compiler test helper as a reusable unit #788

Merged
merged 2 commits into from
Feb 3, 2022

Conversation

paracycle
Copy link
Member

Motivation

We currently have too much magic inside the DslSpec test superclass which makes it hard for other projects to write tests for their own DSL compilers, and it also makes it hard to understand what is going on inside that superclass as well.

Implementation

Extract logic to a reusable module that should work independently of the testing framework used. This module provides helper methods to setup DSL compiler under test and possibly collaborating DSL compilers that should also be activated. Moreover it provides convenience methods like rbi_for and gathered_constants that tests can use for assertions.

While I was refactoring tests, I also took the opportunity to make sure our "no errors raised" assertions didn't end up being intrusive across the whole test suite.

Tests

No new tests.

@paracycle paracycle requested a review from a team February 3, 2022 14:54
Instead replace them with an assertion that generated errors is empty
in the base test class after block. To allow tests to still generate
and test errors, added a `expect_dsl_compiler_errors!` call which sets
a flag to skip generated errors assertion after the test.
@paracycle paracycle force-pushed the uk-refactor-dsl-tests branch from 534b8f8 to ba17012 Compare February 3, 2022 15:14
@paracycle paracycle added the enhancement New feature or request label Feb 3, 2022
@paracycle paracycle changed the title Extract DSL compiler test helper as a reusable unit Expose DSL compiler test helper as a reusable unit Feb 3, 2022
@compiler_class = compiler_class
@other_compiler_classes = T.let([], T::Array[T.class_of(Tapioca::Compilers::Dsl::Base)])
@compiler = T.let(nil, T.nilable(Tapioca::Compilers::Dsl::Base))
@pipeline = T.let(nil, T.nilable(Tapioca::Compilers::DslCompiler))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for later: we need to rename DslCompiler -> DslPipeline

@paracycle paracycle merged commit 1d39bb0 into main Feb 3, 2022
@paracycle paracycle deleted the uk-refactor-dsl-tests branch February 3, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants