Files
sdk/pkg/nnbd_migration/test/front_end/instrumentation_renderer_test.dart
T
Sam Rawlins 360363efc1 Migrator: opt all test files _out_ of null safety.
Well not quite all; migration_cli_test tests are a bit of a different
beast so I am going to tackle them separately. But this fixes over
1000 test failures, and should clean up test output for further
debugging of the flip CL.

Each test file needs to be in a package with a package config file
which spells out that it is _opted out_ of null safety.

Bug: https://github.com/dart-lang/sdk/issues/43883
Change-Id: I583f66119df57031fd80824111923e15e0f91782
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168900
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-23 21:07:04 +00:00

56 lines
2.3 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:nnbd_migration/src/front_end/instrumentation_renderer.dart';
import 'package:nnbd_migration/src/front_end/migration_info.dart';
import 'package:nnbd_migration/src/front_end/path_mapper.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'nnbd_migration_test_base.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(InstrumentationRendererTest);
});
}
@reflectiveTest
class InstrumentationRendererTest extends NnbdMigrationTestBase {
/// Render the instrumentation view for [files].
Future<String> renderViewForTestFiles(
{bool applied = false, bool needsRerun = false}) async {
var files = {convertPath('$projectPath/lib/a.dart'): 'int a = null;'};
await buildInfoForTestFiles(files, includedRoot: projectPath);
var migrationInfo =
MigrationInfo(infos, {}, resourceProvider.pathContext, projectPath);
var instrumentationRenderer = InstrumentationRenderer(
migrationInfo, PathMapper(resourceProvider), applied, needsRerun);
return instrumentationRenderer.render();
}
Future<void> test_appliedStyle() async {
var renderedView = await renderViewForTestFiles(applied: true);
// harmless space in class list due to other potential classes here.
expect(renderedView, contains('<body class="applied ">'));
}
Future<void> test_navigation_containsRoot() async {
var renderedView = await renderViewForTestFiles();
// harmless space in class list due to other potential classes here.
expect(renderedView, contains('<p class="root">$projectPath</p>'));
}
Future<void> test_needsRerunStyle() async {
var renderedView = await renderViewForTestFiles(needsRerun: true);
expect(renderedView, contains('<body class="proposed needs-rerun">'));
}
Future<void> test_notAppliedStyle() async {
var renderedView = await renderViewForTestFiles(applied: false);
// harmless space in class list due to other potential classes here.
expect(renderedView, contains('<body class="proposed ">'));
}
}