File size: 2,406 Bytes
b7f6949
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2014 The Flutter Authors. 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' as io;

import 'package:path/path.dart' as p;

/// To run this script, either:
///
/// ```sh
/// cd dev/customer_testing
/// dart ci.dart [sha]
/// ```
///
/// Or:
///
/// ```sh
/// ./dev/customer_testing/ci.sh
/// ./dev/customer_testing/ci.bat
/// ```
void main(List<String> args) async {
  final String sha;
  if (args.isEmpty) {
    sha = io.File('tests.version').readAsStringSync().trim();
  } else if (args.length == 1) {
    sha = args.first;
  } else {
    io.stderr.writeln('Usage: dart ci.dart [sha]');
    io.exitCode = 1;
    return;
  }

  final String flutterRootPath = p.canonicalize('../../');
  final io.Directory testsCacheDir = io.Directory(
    p.join(flutterRootPath, 'bin', 'cache', 'pkg', 'tests'),
  );

  if (testsCacheDir.existsSync()) {
    io.stderr.writeln('Cleaning up existing repo: ${testsCacheDir.path}');
    testsCacheDir.deleteSync(recursive: true);
  }

  io.stderr.writeln('Cloning flutter/tests');
  final io.Process clone = await io.Process.start('git', <String>[
    'clone',
    '--depth',
    '1',
    'https://github.com/flutter/tests.git',
    testsCacheDir.path,
  ], mode: io.ProcessStartMode.inheritStdio);
  if ((await clone.exitCode) != 0) {
    io.exitCode = 1;
    return;
  }

  io.stderr.writeln('Fetching/checking out $sha');
  final io.Process fetch = await io.Process.start(
    'git',
    <String>['fetch', 'origin', sha],
    mode: io.ProcessStartMode.inheritStdio,
    workingDirectory: testsCacheDir.path,
  );
  if ((await fetch.exitCode) != 0) {
    io.exitCode = 1;
    return;
  }
  final io.Process checkout = await io.Process.start(
    'git',
    <String>['checkout', sha],
    mode: io.ProcessStartMode.inheritStdio,
    workingDirectory: testsCacheDir.path,
  );
  if ((await checkout.exitCode) != 0) {
    io.exitCode = 1;
    return;
  }

  io.stderr.writeln('Running tests...');
  final io.Process test = await io.Process.start('dart', <String>[
    '--enable-asserts',
    'run_tests.dart',
    '--skip-on-fetch-failure',
    '--skip-template',
    p.posix.joinAll(<String>[...p.split(testsCacheDir.path), 'registry', '*.test']),
  ], mode: io.ProcessStartMode.inheritStdio);
  if ((await test.exitCode) != 0) {
    io.exitCode = 1;
    return;
  }
}