Chromium Code Reviews| Index: third_party/pkg/generate_angular_tests.sh |
| diff --git a/third_party/pkg/generate_angular_tests.sh b/third_party/pkg/generate_angular_tests.sh |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..5157e33c32130f939240b92d7a41f0a8f50d2903 |
| --- /dev/null |
| +++ b/third_party/pkg/generate_angular_tests.sh |
| @@ -0,0 +1,127 @@ |
| +#!/bin/bash |
| +# 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. |
| + |
| +# bail on error |
| +set -e |
| + |
| +generate_test_files() { |
| + pushd angular/test > /dev/null |
| + |
| + local out_dir='../../../../pkg/third_party/angular_tests' |
| + |
| + generate_browser_tests |
| + generate_vm_tests |
| + popd > /dev/null |
| +} |
| + |
| +generate_browser_tests() { |
| + local test_file="${out_dir}/browser_test.dart" |
| + local tests=$(find * -name "*_spec.dart" \ |
| + -not -path "playback/*" \ |
| + -not -path "io/*" \ |
| + -not -path "tools/*" \ |
| + -not -path "*/generated_parser_spec.dart") |
| + |
| + mkdir -p "${out_dir}" |
| + echo "$(browser_header)" > "${test_file}" |
|
Siggi Cherem (dart-lang)
2014/01/10 23:26:43
I think you can simplify this as:
browser_head
|
| + |
| + local index=0 |
| + for src_file in ${tests}; do |
| + local import_file="../../../third_party/pkg/angular/test/${src_file}" |
| + echo "import '${import_file}' as test_${index};" >> "${test_file}" |
| + index=$(expr ${index} + 1) |
| + done |
| + |
| + echo "$(browser_main)" >> "${test_file}" |
|
Siggi Cherem (dart-lang)
2014/01/10 23:26:43
same here and below
|
| + |
| + index=0 |
| + for src_file in ${tests}; do |
| + echo "$(test_group)" >> "${test_file}" |
| + index=$(expr ${index} + 1) |
| + done |
| + echo "}" >> "${test_file}" |
| +} |
| + |
| +generate_vm_tests() { |
| + local test_file="${out_dir}/vm_test.dart" |
| + local tests=$(find tools -name "*_spec.dart") |
| + |
| + mkdir -p "${out_dir}" |
| + echo "$(vm_header)" > "${test_file}" |
| + |
| + local index=0 |
| + for src_file in ${tests}; do |
| + local import_file="../../../third_party/pkg/angular/test/${src_file}" |
| + echo "import '${import_file}' as test_${index};" >> "${test_file}" |
| + index=$(expr ${index} + 1) |
| + done |
| + |
| + echo "$(vm_main)" >> "${test_file}" |
| + |
| + index=0 |
| + for src_file in ${tests}; do |
| + echo "$(test_group)" >> "${test_file}" |
| + index=$(expr ${index} + 1) |
| + done |
| + echo "}" >> "${test_file}" |
| +} |
| + |
| +browser_header() { |
| + echo "/// auto-generated by update_angular.sh |
| + |
| +// 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 angular_browser_tests; |
| + |
| +import 'package:angular/mock/module.dart'; |
| +import 'package:unittest/html_individual_config.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +" |
| +} |
| + |
| +browser_main() { |
| + echo " |
| +main() { |
| + useHtmlIndividualConfiguration(); |
| + |
| + setUp(() { |
| + setUpInjector(); |
| + }); |
| +" |
| +} |
| + |
| +test_group() { |
| + echo " |
| + group('${src_file%_spec.dart}', () { |
| + test_${index}.main(); |
| + });" |
| +} |
| + |
| +vm_header() { |
| + echo "/// auto-generated by update_angular.sh |
| + |
| +// 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 angular_vm_tests; |
| + |
| +import 'package:unittest/compact_vm_config.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +" |
| +} |
| + |
| +vm_main() { |
| + echo " |
| +main() { |
| + useCompactVMConfiguration(); |
| +" |
| +} |
| + |
| +generate_test_files |