Skip to content

Commit

Permalink
Added verbose logging of the story being evaluated.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Nov 5, 2024
1 parent bc24479 commit 52783ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion tools/src/tester/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ import type StoryValidator from "./StoryValidator";
import { OpenSearchHttpClient } from 'OpenSearchHttpClient'
import * as ansi from './Ansi'
import _ from 'lodash'
import { Logger } from 'Logger'

export default class TestRunner {
private readonly _http_client: OpenSearchHttpClient
private readonly _story_validator: StoryValidator
private readonly _story_evaluator: StoryEvaluator
private readonly _result_logger: ResultLogger
private readonly _story_files: Record<string, StoryFile[]> = {}
private readonly _logger: Logger

constructor (http_client: OpenSearchHttpClient, story_validator: StoryValidator, story_evaluator: StoryEvaluator, result_logger: ResultLogger) {
constructor (http_client: OpenSearchHttpClient, story_validator: StoryValidator, story_evaluator: StoryEvaluator, result_logger: ResultLogger, logger: Logger) {
this._http_client = http_client
this._story_validator = story_validator
this._story_evaluator = story_evaluator
this._result_logger = result_logger
this._logger = logger
}

async run (story_path: string, version?: string, distribution?: string, dry_run: boolean = false): Promise<{ results: StoryEvaluations, failed: boolean }> {
Expand All @@ -52,6 +55,7 @@ export default class TestRunner {
}

for (const story_file of story_files) {
this._logger.info(`Evaluating ${story_file.display_path} ...`)
const evaluation = this._story_validator.validate(story_file) ?? await this._story_evaluator.evaluate(story_file, version, distribution, dry_run)
results.evaluations.push(evaluation)
this._result_logger.log(evaluation)
Expand Down
2 changes: 1 addition & 1 deletion tools/src/tester/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const supplemental_chapter_evaluator = new SupplementalChapterEvaluator(chapter_
const story_validator = new StoryValidator()
const story_evaluator = new StoryEvaluator(chapter_evaluator, supplemental_chapter_evaluator)
const result_logger = new ConsoleResultLogger(opts.tabWidth, opts.verbose)
const runner = new TestRunner(http_client, story_validator, story_evaluator, result_logger)
const runner = new TestRunner(http_client, story_validator, story_evaluator, result_logger, logger)

runner.run(opts.testsPath, spec.api_version(), opts.opensearchDistribution, opts.dryRun)
.then(
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/tester/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function construct_tester_components (spec_path: string): {
const story_validator = new StoryValidator()
const story_evaluator = new StoryEvaluator(chapter_evaluator, supplemental_chapter_evaluator)
const result_logger = new NoOpResultLogger()
const test_runner = new TestRunner(opensearch_http_client, story_validator, story_evaluator, result_logger)
const test_runner = new TestRunner(opensearch_http_client, story_validator, story_evaluator, result_logger, logger)
return {
specification,
operation_locator,
Expand Down

0 comments on commit 52783ee

Please sign in to comment.