Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c925fa6

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Lay the groundwork for comparing language_2 compilation results between analyzer and CFE.
This CL just adds the compiler=compareAnalyzerCfe option to the test framework, and updates the status files so that no language_2 failures are expected when this "compiler" is used. A placeholder executable has been added to sdk/bin, but it is not wired up yet--that will be done in a future CL. In a future CL I will wire up the placeholder executable to the code in pkg/analyzer_fe_comparison, and fill in the methods in CompareAnalyzerCfeCommandOutput to process the output accordingly. Change-Id: I27439de4ac609cb8b003f157a0ff88d181bfbcae Reviewed-on: https://dart-review.googlesource.com/73561 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
1 parent 4ef1ad0 commit c925fa6

File tree

8 files changed

+125
-11
lines changed

8 files changed

+125
-11
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
3+
# for details. All rights reserved. Use of this source code is governed by a
4+
# BSD-style license that can be found in the LICENSE file.
5+
6+
# TODO(paulberry)
7+
echo "Placeholder text"

pkg/smith/lib/configuration.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ class Compiler extends NamedEnum {
584584
static const precompiler = const Compiler._('precompiler');
585585
static const dart2js = const Compiler._('dart2js');
586586
static const dart2analyzer = const Compiler._('dart2analyzer');
587+
static const compareAnalyzerCfe = const Compiler._('compare_analyzer_cfe');
587588
static const dartdevc = const Compiler._('dartdevc');
588589
static const dartdevk = const Compiler._('dartdevk');
589590
static const appJit = const Compiler._('app_jit');
@@ -601,6 +602,7 @@ class Compiler extends NamedEnum {
601602
precompiler,
602603
dart2js,
603604
dart2analyzer,
605+
compareAnalyzerCfe,
604606
dartdevc,
605607
dartdevk,
606608
appJit,
@@ -653,6 +655,7 @@ class Compiler extends NamedEnum {
653655
];
654656

655657
case Compiler.dart2analyzer:
658+
case Compiler.compareAnalyzerCfe:
656659
return const [Runtime.none];
657660
case Compiler.appJit:
658661
case Compiler.appJitk:
@@ -683,6 +686,7 @@ class Compiler extends NamedEnum {
683686
case Compiler.dartdevk:
684687
return Runtime.chrome;
685688
case Compiler.dart2analyzer:
689+
case Compiler.compareAnalyzerCfe:
686690
return Runtime.none;
687691
case Compiler.appJit:
688692
case Compiler.appJitk:
@@ -705,6 +709,7 @@ class Compiler extends NamedEnum {
705709
Mode get defaultMode {
706710
switch (this) {
707711
case Compiler.dart2analyzer:
712+
case Compiler.compareAnalyzerCfe:
708713
case Compiler.dart2js:
709714
case Compiler.dartdevc:
710715
case Compiler.dartdevk:

tests/language_2/language_2.status

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# for details. All rights reserved. Use of this source code is governed by a
33
# BSD-style license that can be found in the LICENSE file.
44

5+
[ $compiler == app_jit ]
6+
deferred_inheritance_constraints_test/redirecting_constructor: Crash
7+
8+
[ $compiler != compare_analyzer_cfe ]
59
bug34235_test/01: MissingCompileTimeError # Issue 34235
610
mixin_constructor_forwarding/const_constructor_test/none: CompileTimeError # Issue 32223
711
mixin_constructor_forwarding/const_constructor_with_field_test/none: CompileTimeError # Issue 32223
812
mixin_constructor_forwarding/optional_named_parameters_test/none: CompileTimeError # Issue 31543
913
mixin_constructor_forwarding/optional_positional_parameters_test/none: CompileTimeError # Issue 31543
1014

11-
[ $compiler == app_jit ]
12-
deferred_inheritance_constraints_test/redirecting_constructor: Crash
13-
1415
[ $compiler == dart2analyzer ]
1516
double_literals/*: Skip # https://github.com/dart-lang/sdk/issues/34360
1617

@@ -58,9 +59,16 @@ partial_instantiation_static_bounds_check_test/03: MissingCompileTimeError # Iss
5859
[ $compiler != app_jitk && $compiler != dartk && $compiler != dartkb && $compiler != dartkp && $mode == debug && $runtime == vm ]
5960
built_in_identifier_type_annotation_test/set: Crash # Not supported by legacy VM front-end.
6061

61-
[ $compiler != dart2analyzer && $compiler != dart2js && $compiler != dartdevc && !$fasta && $strong ]
62+
[ $compiler != compare_analyzer_cfe && $compiler != dart2analyzer && $compiler != dart2js && $compiler != dartdevc && !$fasta && $strong ]
6263
type_promotion_functions_test: CompileTimeError # Issue 30895: This test requires a complete rewrite for 2.0.
6364

65+
[ $compiler != compare_analyzer_cfe && $compiler != dart2js && !$fasta && $strong ]
66+
compile_time_constant_static5_test/11: CompileTimeError # Issue 30546
67+
compile_time_constant_static5_test/16: CompileTimeError # Issue 30546
68+
compile_time_constant_static5_test/21: CompileTimeError # Issue 30546
69+
compile_time_constant_static5_test/23: CompileTimeError # Issue 30546
70+
type_promotion_more_specific_test/04: CompileTimeError # Issue 30906.
71+
6472
# Detection of compile-time errors that are related to constants can't be fully
6573
# done at the front end, because constants are evaluated at back ends. So, some
6674
# errors aren't detected by fasta, but reported by back ends as compile-time
@@ -82,13 +90,6 @@ implicit_creation/implicit_const_not_default_values_test/e9: MissingCompileTimeE
8290
[ $compiler != dart2js && $compiler != dartdevc && !$checked ]
8391
function_type/*: Skip # Needs checked mode.
8492

85-
[ $compiler != dart2js && !$fasta && $strong ]
86-
compile_time_constant_static5_test/11: CompileTimeError # Issue 30546
87-
compile_time_constant_static5_test/16: CompileTimeError # Issue 30546
88-
compile_time_constant_static5_test/21: CompileTimeError # Issue 30546
89-
compile_time_constant_static5_test/23: CompileTimeError # Issue 30546
90-
type_promotion_more_specific_test/04: CompileTimeError # Issue 30906.
91-
9293
[ $compiler != dart2js && !$fasta && !$strong ]
9394
implicit_creation/implicit_new_constructor_generic_test: Fail # No support for implicit creation.
9495
implicit_creation/implicit_new_constructor_test: Fail # No support for implicit creation.

tools/testing/dart/command.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class Command {
5151
return new AnalysisCommand._(executable, arguments, environmentOverrides);
5252
}
5353

54+
static Command compareAnalyzerCfe(String executable, List<String> arguments,
55+
Map<String, String> environmentOverrides) {
56+
return new CompareAnalyzerCfeCommand._(
57+
executable, arguments, environmentOverrides);
58+
}
59+
5460
static Command specParse(String executable, List<String> arguments,
5561
Map<String, String> environmentOverrides) {
5662
return new SpecParseCommand._(executable, arguments, environmentOverrides);
@@ -429,6 +435,13 @@ class AnalysisCommand extends ProcessCommand {
429435
: super._('dart2analyzer', executable, arguments, environmentOverrides);
430436
}
431437

438+
class CompareAnalyzerCfeCommand extends ProcessCommand {
439+
CompareAnalyzerCfeCommand._(String executable, List<String> arguments,
440+
Map<String, String> environmentOverrides)
441+
: super._('compare_analyzer_cfe', executable, arguments,
442+
environmentOverrides);
443+
}
444+
432445
class SpecParseCommand extends ProcessCommand {
433446
SpecParseCommand._(String executable, List<String> arguments,
434447
Map<String, String> environmentOverrides)

tools/testing/dart/command_output.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,41 @@ class AnalysisCommandOutput extends CommandOutput {
566566
}
567567
}
568568

569+
class CompareAnalyzerCfeCommandOutput extends CommandOutput {
570+
CompareAnalyzerCfeCommandOutput(
571+
Command command,
572+
int exitCode,
573+
bool timedOut,
574+
List<int> stdout,
575+
List<int> stderr,
576+
Duration time,
577+
bool compilationSkipped)
578+
: super(command, exitCode, timedOut, stdout, stderr, time,
579+
compilationSkipped, 0);
580+
581+
Expectation result(TestCase testCase) {
582+
// Handle crashes and timeouts first
583+
if (hasCrashed) return Expectation.crash;
584+
if (hasTimedOut) return Expectation.timeout;
585+
if (hasNonUtf8) return Expectation.nonUtf8Error;
586+
587+
// TODO(paulberry): parse command output
588+
return Expectation.pass;
589+
}
590+
591+
/// Cloned code from member result(), with changes.
592+
/// Delete existing result() function and rename, when status files are gone.
593+
Expectation realResult(TestCase testCase) {
594+
// Handle crashes and timeouts first
595+
if (hasCrashed) return Expectation.crash;
596+
if (hasTimedOut) return Expectation.timeout;
597+
if (hasNonUtf8) return Expectation.nonUtf8Error;
598+
599+
// TODO(paulberry): parse command output
600+
return Expectation.pass;
601+
}
602+
}
603+
569604
class SpecParseCommandOutput extends CommandOutput {
570605
SpecParseCommandOutput(
571606
Command command,
@@ -984,6 +1019,9 @@ CommandOutput createCommandOutput(Command command, int exitCode, bool timedOut,
9841019
if (command is AnalysisCommand) {
9851020
return new AnalysisCommandOutput(
9861021
command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
1022+
} else if (command is CompareAnalyzerCfeCommand) {
1023+
return new CompareAnalyzerCfeCommandOutput(
1024+
command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
9871025
} else if (command is SpecParseCommand) {
9881026
return new SpecParseCommandOutput(
9891027
command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);

tools/testing/dart/compiler_configuration.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ abstract class CompilerConfiguration {
5151
case Compiler.dart2analyzer:
5252
return new AnalyzerCompilerConfiguration(configuration);
5353

54+
case Compiler.compareAnalyzerCfe:
55+
return new CompareAnalyzerCfeCompilerConfiguration(configuration);
56+
5457
case Compiler.dart2js:
5558
return new Dart2jsCompilerConfiguration(configuration);
5659

@@ -962,6 +965,46 @@ class AnalyzerCompilerConfiguration extends CompilerConfiguration {
962965
}
963966
}
964967

968+
/// Configuration for compareAnalyzerCfe.
969+
class CompareAnalyzerCfeCompilerConfiguration extends CompilerConfiguration {
970+
CompareAnalyzerCfeCompilerConfiguration(TestConfiguration configuration)
971+
: super._subclass(configuration);
972+
973+
int get timeoutMultiplier => 4;
974+
975+
String computeCompilerPath() {
976+
String suffix = executableScriptSuffix;
977+
if (_useSdk) {
978+
throw "--use-sdk cannot be used with compiler compare_analyzer_cfe";
979+
}
980+
return 'pkg/analyzer_fe_comparison/bin/compare_sdk_tests$suffix';
981+
}
982+
983+
CommandArtifact computeCompilationArtifact(String tempDir,
984+
List<String> arguments, Map<String, String> environmentOverrides) {
985+
arguments = arguments.toList();
986+
if (!previewDart2) {
987+
throw new ArgumentError('--no-preview-dart-2 not supported');
988+
}
989+
990+
// Since this is not a real compilation, no artifacts are produced.
991+
return new CommandArtifact([
992+
Command.compareAnalyzerCfe(
993+
computeCompilerPath(), arguments, environmentOverrides)
994+
], null, null);
995+
}
996+
997+
List<String> computeRuntimeArguments(
998+
RuntimeConfiguration runtimeConfiguration,
999+
TestInformation info,
1000+
List<String> vmOptions,
1001+
List<String> sharedOptions,
1002+
List<String> originalArguments,
1003+
CommandArtifact artifact) {
1004+
return <String>[];
1005+
}
1006+
}
1007+
9651008
/// Configuration for spec_parser.
9661009
class SpecParserCompilerConfiguration extends CompilerConfiguration {
9671010
SpecParserCompilerConfiguration(TestConfiguration configuration)

tools/testing/dart/options.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ none: Do not compile the Dart code.
9696
precompiler: Compile into AOT snapshot before running the test.
9797
dart2js: Compile to JavaScript using dart2js.
9898
dart2analyzer: Perform static analysis on Dart code using the analyzer.
99+
compareAnalyzerCfe: Compare analyzer and common front end representations.
99100
app_jit: Compile the Dart code into an app snapshot.
100101
app_jitk: Compile the Dart code into Kernel and then into an app snapshot.
101102
dartk: Compile the Dart code into Kernel before running test.

tools/testing/dart/status_reporter.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ final _combinations = {
1313
'archs': ['x64'],
1414
'compiler': 'dart2analyzer'
1515
},
16+
{
17+
'runtimes': ['none'],
18+
'modes': ['release'],
19+
'archs': ['x64'],
20+
'compiler': 'compare_analyzer_cfe'
21+
},
1622
{
1723
'runtimes': ['vm'],
1824
'modes': ['debug', 'release'],

0 commit comments

Comments
 (0)