Skip to content

Commit 04462d5

Browse files
committed
test: align compiler regression instrumentation with native APIs
1 parent 2b6744b commit 04462d5

7 files changed

Lines changed: 15 additions & 28 deletions

File tree

‎tests/e2e/scripts/compiler_differential/helpers.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ def _perturbed(self, **changes):
9999
_record.write(json.dumps({"kind": "legacy_fallback", "site": "orders.sql"}) + "\\n")
100100
"""
101101

102-
MODEL_ANALYSIS_SABOTAGE: str = """
103-
import sqlbuild._native as native
102+
FALLBACK_RECORD_PERTURBATION: str = """
103+
from sqlbuild.compiler.frontier._helpers.process_recorder import process_recorder
104104
105-
native.start_model_analysis_session = lambda *_args: None
105+
recorder = process_recorder()
106+
if recorder is not None:
107+
recorder.record(site="analysis_session", kind="session")
106108
"""
107109

108110
_BROKEN_REF_FILES: dict[str, str] = {

‎tests/e2e/scripts/compiler_differential/test_compiler_differential.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ def test_given_failure_expectation_when_code_is_not_the_first_error_then_harness
382382
),
383383
expected_sites=frozenset(
384384
{
385-
"compiler/compile/_helpers/analysis/validation.py:"
386-
"_validate_sql_syntax_with_message parse_one",
385+
"compiler/compile/_helpers/analysis/required_columns.py:"
386+
"resolve_required_external_columns parse_one",
387387
}
388388
),
389389
expected_deferrals=frozenset(),

‎tests/e2e/scripts/compiler_differential/test_native_fallback_gate.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from scripts.compiler_differential.main.differential import run_compiler_differential
1010
from tests.e2e.scripts.compiler_differential._test_types import NativeFallbackGateTestCase
1111
from tests.e2e.scripts.compiler_differential.helpers import (
12-
MODEL_ANALYSIS_SABOTAGE,
12+
FALLBACK_RECORD_PERTURBATION,
1313
harness_arguments,
1414
write_native_perturbation,
1515
)
@@ -42,12 +42,12 @@
4242
),
4343
),
4444
NativeFallbackGateTestCase(
45-
description="preview_model_analysis_sabotaged_to_python_fails",
46-
perturbation=MODEL_ANALYSIS_SABOTAGE,
45+
description="unexpected_preview_fallback_record_fails",
46+
perturbation=FALLBACK_RECORD_PERTURBATION,
4747
appended_entries="",
4848
expected_exit_code=1,
4949
expected_lines=(
50-
"Native fallback allow-list: native-preview model_analysis analysis_session "
50+
"Native fallback allow-list: native-preview analysis_session analysis_session "
5151
"session (project): ",
5252
"Compiler differential FAILED: 0 of 1 projects differ",
5353
),

‎tests/e2e/src/sqlbuild/cli/commands/main/compile/_test_types.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,9 @@ class RetiredCompilerCacheTestCase:
797797

798798
@dataclass(frozen=True)
799799
class SharedCacheKeyTestCase:
800-
"""A model analysis schedule under which two models share one analysis cache key."""
800+
"""Expected parity when identical SQL models share native cached analysis."""
801801

802802
description: str
803-
schedule: Callable[[pytest.MonkeyPatch], None]
804803
expected_matches_uncached: bool = True
805804

806805

‎tests/e2e/src/sqlbuild/cli/commands/main/compile/helpers.py‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import sqlbuild.cli.compile_reuse._helpers.attempt as reuse_attempt
3636
import sqlbuild.cli.compile_reuse._helpers.project_files as reuse_project_files
3737
import sqlbuild.cli.compile_reuse._helpers.store as reuse_store
38-
import sqlbuild.compiler.compile._helpers.assembly.project as project_assembly
3938
import sqlbuild.compiler.compile._helpers.diagnostics.recovery as diagnostic_recovery
4039
import sqlbuild.compiler.compile._helpers.macro_bridge.call_store as call_store_module
4140
import sqlbuild.compiler.compile._helpers.native_stages.assembly as native_stages
@@ -3879,12 +3878,6 @@ def twin_header_changed(root: Path) -> None:
38793878
)
38803879

38813880

3882-
def analyze_in_one_batch(monkeypatch: pytest.MonkeyPatch) -> None:
3883-
"""Analyze every model in one batch, without dependency-ordered binding."""
3884-
3885-
monkeypatch.setattr(project_assembly, "binding_schema_for_model", lambda **_kwargs: None)
3886-
3887-
38883881
def star_chain_added(root: Path) -> None:
38893882
"""Add two models that each select every column of the one before, below staging orders."""
38903883

@@ -4952,11 +4945,10 @@ def engine_in_process_compile(
49524945

49534946
class NativeTypeAnswers(NamedTuple):
49544947
"""What the native type system answered in one compile: each Python-side normalization,
4955-
contract results that compared at least one typed column, and contract handbacks."""
4948+
and contract results that compared at least one typed column."""
49564949

49574950
normalized: list[bool]
49584951
typed_comparisons: int
4959-
handbacks: int
49604952

49614953

49624954
def type_system_engine_compile(
@@ -4983,7 +4975,6 @@ def recorded(type_sql: str, dialect: str) -> object:
49834975
def recorded_contracts(request: NativeContractRequest) -> list[NativeContractOutcome]:
49844976
outcomes: list[NativeContractOutcome] = evaluate_contracts(request)
49854977
contract_statuses.update(native_contract_statuses(request=request, outcomes=outcomes))
4986-
contract_statuses["handbacks"] += sum(deferral is not None for deferral, _ in outcomes)
49874978
return outcomes
49884979

49894980
type_normalization.normalize_type.cache_clear()
@@ -4997,7 +4988,6 @@ def recorded_contracts(request: NativeContractRequest) -> list[NativeContractOut
49974988
return run, NativeTypeAnswers(
49984989
normalized=normalized,
49994990
typed_comparisons=contract_statuses["typed_comparisons"],
5000-
handbacks=contract_statuses["handbacks"],
50014991
)
50024992

50034993

‎tests/e2e/src/sqlbuild/cli/commands/main/compile/test_compile_incremental_edits.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
RandomEditChain,
2222
adapter_switched,
2323
add_external_flavor_macro,
24-
analyze_in_one_batch,
2524
build_between,
2625
change_adapter_lexical_rules,
2726
compare_incremental_compile,
@@ -411,9 +410,7 @@ def test_given_broken_cache_invalidation_when_compiling_an_edit_then_the_oracle_
411410

412411
@pytest.mark.parametrize(
413412
"test_case",
414-
[
415-
SharedCacheKeyTestCase(description="one_batch", schedule=analyze_in_one_batch),
416-
],
413+
[SharedCacheKeyTestCase(description="native_dependency_order")],
417414
ids=lambda case: case.description,
418415
)
419416
def test_given_models_sharing_an_analysis_cache_key_when_upstream_changes_then_it_matches_uncached(
@@ -424,7 +421,6 @@ def test_given_models_sharing_an_analysis_cache_key_when_upstream_changes_then_i
424421
) -> None:
425422
project_dir: Path = compile_reuse_project
426423
enable_compile_reuse(monkeypatch)
427-
test_case.schedule(monkeypatch)
428424
star_chain_with_twin_added(project_dir)
429425
assert compile_in_process(project_dir=project_dir) == 0
430426
staging_extra_flag(project_dir)

‎tests/e2e/src/sqlbuild/cli/commands/main/compile/test_native_type_system.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_given_contract_types_when_compiling_with_each_engine_then_reports_are_e
170170
assert report_without_engine(preview_run) == report_without_engine(native_run)
171171
assert preview_run.compiled == native_run.compiled
172172
assert native_answers == preview_answers
173-
assert (native_answers.typed_comparisons >= 1, native_answers.handbacks) == (True, 0)
173+
assert native_answers.typed_comparisons >= 1
174174

175175

176176
if __name__ == "__main__":

0 commit comments

Comments
 (0)