| // Copyright (c) 2018, 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:expect/minitest.dart'; |
| |
| import 'package:smith/smith.dart'; |
| |
| void main() { |
| group("TestMatrix.fromJson()", () { |
| test("parses configurations", () { |
| var testMatrix = TestMatrix.fromJson({ |
| "configurations": { |
| "x64-dart2js-debug-vm-linux": <String, dynamic>{ |
| "options": <String, dynamic>{"enable-asserts": true}, |
| }, |
| "x64-dartdevc-vm-linux": <String, dynamic>{ |
| "options": <String, dynamic>{ |
| "mode": "release", |
| "enable-asserts": true |
| }, |
| }, |
| } |
| }); |
| |
| expect( |
| testMatrix.configurations[0], |
| equals(Configuration("x64-dart2js-debug-vm-linux", Architecture.x64, |
| Compiler.dart2js, Mode.debug, Runtime.vm, System.linux, |
| enableAsserts: true))); |
| expect( |
| testMatrix.configurations[1], |
| equals(Configuration("x64-dartdevc-vm-linux", Architecture.x64, |
| Compiler.dartdevc, Mode.release, Runtime.vm, System.linux, |
| enableAsserts: true))); |
| }); |
| |
| test("error if expanded configuration names collide", () { |
| expectJsonError( |
| 'Configuration "none-x64-dart2js-debug-vm-linux" already exists.', { |
| "configurations": { |
| "none-x64-dart2js-debug-vm-linux": <String, dynamic>{}, |
| "none-(x64|ia32)-dart2js-debug-vm-linux": <String, dynamic>{}, |
| } |
| }); |
| }); |
| |
| test("error if two configurations have same options", () { |
| expectJsonError( |
| 'Configuration "two-x64-dart2js-debug-vm-linux" is identical to ' |
| '"one-x64-dart2js-debug-vm-linux".', |
| { |
| "configurations": { |
| "one-x64-dart2js-debug-vm-linux": <String, dynamic>{ |
| "options": <String, dynamic>{"enable-asserts": true} |
| }, |
| "two-x64-dart2js-debug-vm-linux": <String, dynamic>{ |
| "options": <String, dynamic>{"enable-asserts": true} |
| }, |
| } |
| }); |
| }); |
| }); |
| } |
| |
| void expectJsonError(String error, Map<String, dynamic> json) { |
| try { |
| var testMatrix = TestMatrix.fromJson(json); |
| fail("Expected FormatException but got $testMatrix."); |
| } on FormatException catch (ex) { |
| expect(ex.message, equals(error)); |
| } |
| } |