Files
sdk/pkg/dartdev/test/commands/create_integration_test.dart
T
Ben Konyi 628193450a [ CLI ] Check for valid package names and '.' when creating new projects
Ensures that Dart projects created using 'dart create' are valid
packages.

Fixes https://github.com/dart-lang/sdk/issues/43216.

Change-Id: I1e38ba722f24a247e64f077d35c8e74c051c4908
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193825
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-04-01 23:58:47 +00:00

55 lines
1.5 KiB
Dart

// Copyright (c) 2021, 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:io';
import 'package:dartdev/src/commands/create.dart';
import 'package:test/test.dart';
import '../utils.dart';
void main() {
group('create integration', defineCreateTests, timeout: longTimeout);
}
void defineCreateTests() {
TestProject p;
setUp(() => p = null);
tearDown(() => p?.dispose());
// Create tests for each template.
for (String templateId in CreateCommand.legalTemplateIds) {
test(templateId, () {
p = project();
ProcessResult createResult = p.runSync([
'create',
'--force',
'--template',
templateId,
'template_project',
]);
expect(createResult.exitCode, 0, reason: createResult.stderr);
// Validate that the project analyzes cleanly.
// TODO: Should we use --fatal-infos here?
ProcessResult analyzeResult =
p.runSync(['analyze'], workingDir: p.dir.path);
expect(analyzeResult.exitCode, 0, reason: analyzeResult.stdout);
// Validate that the code is well formatted.
ProcessResult formatResult = p.runSync([
'format',
'--output',
'none',
'--set-exit-if-changed',
'template_project',
]);
expect(formatResult.exitCode, 0, reason: formatResult.stdout);
});
}
}