mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
[dds] Fix deserialisation of env vars in DAP
Change-Id: Ia3da6d4abdfd41b4b4f6631fd82d8680ee1727b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239309 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
0640f6e1e3
commit
8e90d6ac15
2 changed files with 37 additions and 1 deletions
|
@ -217,7 +217,7 @@ class DartCommonLaunchAttachRequestArguments extends RequestArguments {
|
|||
: restart = obj['restart'],
|
||||
name = obj['name'] as String?,
|
||||
cwd = obj['cwd'] as String?,
|
||||
env = obj['env'] as Map<String, String>?,
|
||||
env = (obj['env'] as Map<String, Object?>?)?.cast<String, String>(),
|
||||
additionalProjectPaths =
|
||||
(obj['additionalProjectPaths'] as List?)?.cast<String>(),
|
||||
debugSdkLibraries = obj['debugSdkLibraries'] as bool?,
|
||||
|
|
36
pkg/dds/test/dap/arguments_test.dart
Normal file
36
pkg/dds/test/dap/arguments_test.dart
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) 2022, 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:convert';
|
||||
|
||||
import 'package:dds/dap.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() {
|
||||
group('DartLaunchRequestArguments', () {
|
||||
test('handles only required arguments', () async {
|
||||
final json = '{"program":"a"}';
|
||||
final decoded = DartLaunchRequestArguments.fromJson(jsonDecode(json));
|
||||
expect(decoded.program, 'a');
|
||||
final encoded = jsonEncode(decoded.toJson());
|
||||
expect(encoded, json);
|
||||
});
|
||||
|
||||
test('handles env variables map', () async {
|
||||
final json = '{"env":{"a":"b"},"program":"a"}';
|
||||
final decoded = DartLaunchRequestArguments.fromJson(jsonDecode(json));
|
||||
expect(decoded.env!['a'], 'b');
|
||||
final encoded = jsonEncode(decoded.toJson());
|
||||
expect(encoded, json);
|
||||
});
|
||||
|
||||
test('handles additional project paths list', () async {
|
||||
final json = '{"additionalProjectPaths":["a","b"],"program":"a"}';
|
||||
final decoded = DartLaunchRequestArguments.fromJson(jsonDecode(json));
|
||||
expect(decoded.additionalProjectPaths, ['a', 'b']);
|
||||
final encoded = jsonEncode(decoded.toJson());
|
||||
expect(encoded, json);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue