LCOV - code coverage report
Current view: top level - test-0.12.24+8/lib/src/backend - suite.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 2 8 25.0 %
Date: 2017-10-10 20:17:03 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
       2             : // for details. All rights reserved. Use of this source code is governed by a
       3             : // BSD-style license that can be found in the LICENSE file.
       4             : 
       5             : import 'group.dart';
       6             : import 'metadata.dart';
       7             : import 'operating_system.dart';
       8             : import 'test.dart';
       9             : import 'test_platform.dart';
      10             : 
      11             : /// A test suite.
      12             : ///
      13             : /// A test suite is a set of tests that are intended to be run together and that
      14             : /// share default configuration.
      15             : class Suite {
      16             :   /// The platform on which the suite is running, or `null` if that platform is
      17             :   /// unknown.
      18             :   final TestPlatform platform;
      19             : 
      20             :   /// The operating system on which the suite is running, or `null` if that
      21             :   /// operating system is unknown.
      22             :   ///
      23             :   /// This will always be `null` if [platform] is `null`.
      24             :   final OperatingSystem os;
      25             : 
      26             :   /// The path to the Dart test suite, or `null` if that path is unknown.
      27             :   final String path;
      28             : 
      29             :   /// The metadata associated with this test suite.
      30             :   ///
      31             :   /// This is a shortcut for [group.metadata].
      32           0 :   Metadata get metadata => group.metadata;
      33             : 
      34             :   /// The top-level group for this test suite.
      35             :   final Group group;
      36             : 
      37             :   /// Creates a new suite containing [entires].
      38             :   ///
      39             :   /// If [platform] and/or [os] are passed, [group] is filtered to match that
      40             :   /// platform information.
      41             :   ///
      42             :   /// If [os] is passed without [platform], throws an [ArgumentError].
      43             :   Suite(Group group, {this.path, TestPlatform platform, OperatingSystem os})
      44             :       : platform = platform,
      45             :         os = os,
      46          10 :         group = _filterGroup(group, platform, os);
      47             : 
      48             :   /// Returns [entries] filtered according to [platform] and [os].
      49             :   ///
      50             :   /// Gracefully handles [platform] being null.
      51             :   static Group _filterGroup(
      52             :       Group group, TestPlatform platform, OperatingSystem os) {
      53             :     if (platform == null && os != null) {
      54           0 :       throw new ArgumentError.value(
      55             :           null, "os", "If os is passed, platform must be passed as well");
      56             :     }
      57             : 
      58             :     if (platform == null) return group;
      59           5 :     var filtered = group.forPlatform(platform, os: os);
      60             :     if (filtered != null) return filtered;
      61           0 :     return new Group.root([], metadata: group.metadata);
      62             :   }
      63             : 
      64             :   /// Returns a new suite with all tests matching [test] removed.
      65             :   ///
      66             :   /// Unlike [GroupEntry.filter], this never returns `null`. If all entries are
      67             :   /// filtered out, it returns an empty suite.
      68             :   Suite filter(bool callback(Test test)) {
      69           0 :     var filtered = group.filter(callback);
      70           0 :     if (filtered == null) filtered = new Group.root([], metadata: metadata);
      71           0 :     return new Suite(filtered, platform: platform, os: os, path: path);
      72             :   }
      73             : }

Generated by: LCOV version 1.13