Skip to content

Commit 22d85c6

Browse files
committed
Fix --fatal-deprecation adding obsolete ones
See also #2647
1 parent 20a59ee commit 22d85c6

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/src/deprecation.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ enum Deprecation {
224224
var range = VersionRange(max: version, includeMax: true);
225225
return {
226226
for (var deprecation in Deprecation.values)
227-
if (deprecation.deprecatedIn.andThen(range.allows) ?? false)
227+
if ((deprecation.deprecatedIn.andThen(range.allows) ?? false) &&
228+
(deprecation.obsoleteIn.andThen((v) => !range.allows(v)) ?? true))
228229
deprecation,
229230
};
230231
}

test/deprecations_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ library;
88
import 'package:test/test.dart';
99

1010
import 'package:sass/sass.dart';
11+
import 'package:pub_semver/pub_semver.dart';
1112

1213
void main() {
1314
// Deprecated in all version of Dart Sass
@@ -151,6 +152,36 @@ void main() {
151152
);
152153
});
153154
});
155+
156+
group('Deprecation.forVersion', () {
157+
test('includes deprecation if not obsolete', () {
158+
final version = Version.parse('1.91.0');
159+
final deprecations = Deprecation.forVersion(version);
160+
161+
expect(
162+
deprecations,
163+
contains(Deprecation.mixedDecls),
164+
reason: 'mixed-decls is obsolete in 1.92, should be fatal at 1.91',
165+
);
166+
});
167+
168+
test('excludes obsolete deprecations', () {
169+
final version = Version.parse('1.93.0');
170+
final deprecations = Deprecation.forVersion(version);
171+
172+
expect(
173+
deprecations,
174+
isNot(contains(Deprecation.mixedDecls)),
175+
reason: 'mixed-decls is obsolete in 1.92, should not be fatal at 1.93',
176+
);
177+
178+
expect(
179+
deprecations,
180+
contains(Deprecation.functionUnits),
181+
reason: 'functionUnits is deprecated but not obsolete, should be fatal',
182+
);
183+
});
184+
});
154185
}
155186

156187
/// Confirms that [source] will error if [deprecation] is fatal.

0 commit comments

Comments
 (0)