Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: packages/dart_style/test/utils.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: packages/dart_style/test/utils.dart
diff --git a/packages/dart_style/test/utils.dart b/packages/dart_style/test/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2c555d033826334885ba3ea667d1626299e69468
--- /dev/null
+++ b/packages/dart_style/test/utils.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2014, 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.
+
+library dart_style.test.utils;
+
+import 'dart:io';
+
+import 'package:path/path.dart' as p;
+import 'package:scheduled_test/descriptor.dart' as d;
+import 'package:scheduled_test/scheduled_process.dart';
+import 'package:scheduled_test/scheduled_test.dart';
+
+const unformattedSource = 'void main() => print("hello") ;';
+const formattedSource = 'void main() => print("hello");\n';
+
+/// Runs the command line formatter, passing it [args].
+ScheduledProcess runFormatter([List<String> args]) {
+ if (args == null) args = [];
+
+ var formatterPath = p.join("bin", "format.dart");
+
+ args.insert(0, formatterPath);
+
+ // Use the same package root, if there is one.
+ if (Platform.packageRoot.isNotEmpty) {
+ args.insert(0, "--package-root=${Platform.packageRoot}");
+ }
+
+ return new ScheduledProcess.start(Platform.executable, args);
+}
+
+/// Runs the command line formatter, passing it the test directory followed by
+/// [args].
+ScheduledProcess runFormatterOnDir([List<String> args]) {
+ if (args == null) args = [];
+ return runFormatter([d.defaultRoot]..addAll(args));
+}
+
+/// Set up the scheduled test suite.
+///
+/// Configures the unit test output and makes a sandbox directory for the
+/// scheduled tests to run in.
+void setUpTestSuite() {
+ // Make a sandbox directory for the scheduled tests to run in.
+ setUp(() {
+ var tempDir = Directory.systemTemp.createTempSync('dart_style.test.');
+ d.defaultRoot = tempDir.path;
+
+ currentSchedule.onComplete.schedule(() {
+ d.defaultRoot = null;
+ return tempDir.delete(recursive: true);
+ });
+ });
+}
« no previous file with comments | « packages/dart_style/test/splitting/variables.stmt ('k') | packages/dart_style/test/whitespace/._blocks.stmt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698