|
18 | 18 | racket/match |
19 | 19 | racket/port |
20 | 20 | racket/pretty |
| 21 | + racket/set |
21 | 22 | racket/string |
22 | 23 | rackunit |
23 | 24 | rebellion/base/comparator |
|
33 | 34 | rebellion/type/tuple |
34 | 35 | resyntax |
35 | 36 | resyntax/base |
| 37 | + resyntax/private/analysis |
| 38 | + resyntax/private/analyzer |
36 | 39 | resyntax/private/logger |
37 | 40 | resyntax/private/refactoring-result |
38 | 41 | resyntax/private/source |
|
86 | 89 |
|
87 | 90 | (define current-suite-under-test (make-parameter (refactoring-suite #:rules '()))) |
88 | 91 |
|
| 92 | +;; Additional analyzers that should be included when running analysis tests |
| 93 | +(define current-analyzers-under-test (make-parameter (set))) |
| 94 | + |
89 | 95 |
|
90 | 96 | (define (clear-suites-under-test!) |
91 | | - (current-suite-under-test (refactoring-suite #:rules '()))) |
| 97 | + (current-suite-under-test (refactoring-suite #:rules '())) |
| 98 | + (current-analyzers-under-test (set))) |
92 | 99 |
|
93 | 100 |
|
94 | | -(define (add-suite-under-test! suite) |
95 | | - (define current-rules (refactoring-suite-rules (current-suite-under-test))) |
96 | | - (define new-rules (append current-rules (refactoring-suite-rules suite))) |
97 | | - (current-suite-under-test (refactoring-suite #:rules new-rules))) |
| 101 | +(define (add-suite-under-test! suite-or-analyzer) |
| 102 | + (cond |
| 103 | + [(refactoring-suite? suite-or-analyzer) |
| 104 | + (define current-rules (refactoring-suite-rules (current-suite-under-test))) |
| 105 | + (define new-rules (append current-rules (refactoring-suite-rules suite-or-analyzer))) |
| 106 | + (current-suite-under-test (refactoring-suite #:rules new-rules))] |
| 107 | + [(expansion-analyzer? suite-or-analyzer) |
| 108 | + (current-analyzers-under-test (set-add (current-analyzers-under-test) suite-or-analyzer))] |
| 109 | + [else |
| 110 | + (raise-argument-error 'add-suite-under-test! |
| 111 | + "(or/c refactoring-suite? expansion-analyzer?)" |
| 112 | + suite-or-analyzer)])) |
98 | 113 |
|
99 | 114 |
|
100 | 115 | (define current-header (make-parameter (code-block ""))) |
|
243 | 258 |
|
244 | 259 | (define-check (check-suite-analysis program context-list target property-key expected-value) |
245 | 260 | (define suite (current-suite-under-test)) |
| 261 | + (define extra-analyzers (current-analyzers-under-test)) |
246 | 262 | (set! program (code-block-append (current-header) program)) |
247 | 263 | (define program-src (string-source (code-block-raw-string program))) |
248 | 264 | (define-values (call-with-logs-captured build-logs-info) (make-log-capture-utilities)) |
249 | 265 |
|
| 266 | + ;; Combine analyzers from the suite and any additional analyzers |
| 267 | + (define all-analyzers |
| 268 | + (set-union (refactoring-suite-analyzers suite) extra-analyzers)) |
| 269 | + |
250 | 270 | (define actual-props |
251 | 271 | (call-with-logs-captured |
252 | | - (λ () (reysntax-analyze-for-properties-only program-src)))) |
| 272 | + (λ () |
| 273 | + (define full-source (source->string program-src)) |
| 274 | + (if (string-prefix? full-source "#lang racket") |
| 275 | + (source-code-analysis-added-syntax-properties |
| 276 | + (source-analyze program-src #:analyzers all-analyzers)) |
| 277 | + (syntax-property-bundle))))) |
253 | 278 |
|
254 | 279 | (define target-src (string-source (string-trim (code-block-raw-string target)))) |
255 | 280 | (define context-src-list |
|
0 commit comments