Skip to content

Commit

Permalink
Version 3.4.0-238.0.dev
Browse files Browse the repository at this point in the history
Merge a0b6f1e into dev
  • Loading branch information
Dart CI committed Mar 15, 2024
2 parents 3c01ee8 + a0b6f1e commit 2241333
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/test_runner/lib/src/command_output.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ class FastaCommandOutput extends CompilationCommandOutput
/// The test runner only validates the first line of the message, and not the
/// suggested fixes.
static final _errorRegexp = RegExp(
r"^(?:([^:]+):(\d+):(\d+): )?(Context|Error|Warning): (.*)$",
r"^(?:([^:\n\r]+):(\d+):(\d+): )?(Context|Error|Warning): (.*)$",
multiLine: true);

FastaCommandOutput(super.command, super.exitCode, super.hasTimedOut,
Expand Down
187 changes: 187 additions & 0 deletions pkg/test_runner/test/parse_error_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
// Copyright (c) 2024, 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 'dart:io';

import 'package:expect/expect.dart';
import 'package:path/path.dart' as p;
import 'package:test_runner/src/command_output.dart';
import 'package:test_runner/src/static_error.dart';

void _checkError(StaticError error,
{required String path,
required int line,
required int column,
required String message}) {
Expect.equals(p.relative(path, from: Directory.current.path), error.path);
Expect.equals(line, error.line);
Expect.equals(column, error.column);
Expect.equals(message, error.message);
}

void main() {
// TODO(55202): Add general testing of CFE and analyzer error parsing.
testCfeErrors();
}

void testCfeErrors() {
_testMultipleCfeErrors();
}

/// Regression test for parsing multiple errors.
void _testMultipleCfeErrors() {
var errors = <StaticError>[];
var warnings = <StaticError>[];
FastaCommandOutput.parseErrors('''
tests/language/explicit_type_instantiation_parsing_test.dart:171:26: Error: Cannot access static member on an instantiated generic class.
Try removing the type arguments or placing them after the member name.
expect1<Class>(Z<X, X>.instance);
^^^^^^^^
tests/language/explicit_type_instantiation_parsing_test.dart:232:6: Error: A comparison expression can't be an operand of another comparison expression.
Try putting parentheses around one of the comparisons.
X<2>(2);
^
tests/language/explicit_type_instantiation_parsing_test.dart:236:6: Error: A comparison expression can't be an operand of another comparison expression.
Try putting parentheses around one of the comparisons.
X<2>;
^
tests/language/explicit_type_instantiation_parsing_test.dart:236:7: Error: Expected an identifier, but got ';'.
Try inserting an identifier before ';'.
X<2>;
^
tests/language/explicit_type_instantiation_parsing_test.dart:242:6: Error: A comparison expression can't be an operand of another comparison expression.
Try putting parentheses around one of the comparisons.
X<2>.instance; // Not type argument.
^
tests/language/explicit_type_instantiation_parsing_test.dart:242:7: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
X<2>.instance; // Not type argument.
^
tests/language/explicit_type_instantiation_parsing_test.dart:248:6: Error: A comparison expression can't be an operand of another comparison expression.
Try putting parentheses around one of the comparisons.
X<2>.any;
^
tests/language/explicit_type_instantiation_parsing_test.dart:248:7: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
X<2>.any;
^
tests/language/explicit_type_instantiation_parsing_test.dart:255:8: Error: Member not found: 'any'.
X<X>.any; // Invalid, Class does not have any static `any` member.
^^^
tests/language/explicit_type_instantiation_parsing_test.dart:259:8: Error: Cannot access static member on an instantiated generic class.
Try removing the type arguments or placing them after the member name.
X<X>.instance; // Does have static `instance` member, can't access this way.
^^^^^^^^
tests/language/explicit_type_instantiation_parsing_test.dart:265:6: Error: A comparison expression can't be an operand of another comparison expression.
Try putting parentheses around one of the comparisons.
X<X>2;
^
tests/language/explicit_type_instantiation_parsing_test.dart:272:6: Error: A comparison expression can't be an operand of another comparison expression.
Try putting parentheses around one of the comparisons.
X<X>-1;
^
tests/language/explicit_type_instantiation_parsing_test.dart:277:7: Error: A comparison expression can't be an operand of another comparison expression.
Try putting parentheses around one of the comparisons.
f1<X> - 1;
^
tests/language/explicit_type_instantiation_parsing_test.dart:207:12: Warning: Operand of null-aware operation '!' has type 'Type' which excludes null.
- 'Type' is from 'dart:core'.
expect1((Z<X, X>)![1].asBool); // ignore: unnecessary_non_null_assertion
^
''', errors, warnings);

var path = 'tests/language/explicit_type_instantiation_parsing_test.dart';

Expect.equals(13, errors.length);
Expect.equals(1, warnings.length);

_checkError(errors[0],
path: path,
line: 171,
column: 26,
message: "Cannot access static member on an instantiated generic class.");

_checkError(errors[1],
path: path,
line: 232,
column: 6,
message:
"A comparison expression can't be an operand of another comparison expression.");

_checkError(errors[2],
path: path,
line: 236,
column: 6,
message:
"A comparison expression can't be an operand of another comparison expression.");

_checkError(errors[3],
path: path,
line: 236,
column: 7,
message: "Expected an identifier, but got ';'.");

_checkError(errors[4],
path: path,
line: 242,
column: 6,
message:
"A comparison expression can't be an operand of another comparison expression.");

_checkError(errors[5],
path: path,
line: 242,
column: 7,
message: "Expected an identifier, but got '.'.");

_checkError(errors[6],
path: path,
line: 248,
column: 6,
message:
"A comparison expression can't be an operand of another comparison expression.");

_checkError(errors[7],
path: path,
line: 248,
column: 7,
message: "Expected an identifier, but got '.'.");

_checkError(errors[8],
path: path, line: 255, column: 8, message: "Member not found: 'any'.");

_checkError(errors[9],
path: path,
line: 259,
column: 8,
message: "Cannot access static member on an instantiated generic class.");

_checkError(errors[10],
path: path,
line: 265,
column: 6,
message:
"A comparison expression can't be an operand of another comparison expression.");

_checkError(errors[11],
path: path,
line: 272,
column: 6,
message:
"A comparison expression can't be an operand of another comparison expression.");

_checkError(errors[12],
path: path,
line: 277,
column: 7,
message:
"A comparison expression can't be an operand of another comparison expression.");

_checkError(warnings[0],
path: path,
line: 207,
column: 12,
message:
"Operand of null-aware operation '!' has type 'Type' which excludes null.");
}
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 4
PATCH 0
PRERELEASE 237
PRERELEASE 238
PRERELEASE_PATCH 0

0 comments on commit 2241333

Please sign in to comment.