#!/usr/bin/env bash
# Copyright (c) 2018, 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.

# Analyze Dart code in the flutter/flutter repo.

set -ex

checkout=$(pwd)
dart=$checkout/out/ReleaseX64/dart-sdk/bin/dart
sdk=$checkout/out/ReleaseX64/dart-sdk
tmpdir=$(mktemp -d)
cleanup() {
  rm -rf "$tmpdir"
}
trap cleanup EXIT HUP INT QUIT TERM PIPE
cd "$tmpdir"

git clone --single-branch -vv \
  https://dart.googlesource.com/external/github.com/flutter/flutter

cd flutter

bin/flutter config --no-analytics

pinned_dart_sdk=$(cat bin/cache/dart-sdk/revision)
patch=$checkout/tools/patches/flutter-engine/${pinned_dart_sdk}.flutter.patch
if [ -e "$patch" ]; then
  git apply $patch
fi

bin/flutter update-packages

# Analyze the flutter/flutter source code.
$dart --enable-asserts dev/bots/analyze.dart --dart-sdk $sdk

# Test flutter's use of data-driven fixes.
$dart fix packages/flutter/test_fixes --compare-to-golden

# Analyze the sample code in dartdoc snippets.
PUB_CACHE=$checkout/.pub_cache $dart dev/bots/analyze_sample_code.dart

#!/usr/bin/env bash
# Copyright (c) 2018, 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.

# Analyze Dart code in the flutter/flutter repo.

set -ex

checkout=$(pwd)
dart=$checkout/out/ReleaseX64/dart-sdk/bin/dart
sdk=$checkout/out/ReleaseX64/dart-sdk
tmpdir=$(mktemp -d)
cd "$tmpdir"

git clone --single-branch -vv \
  https://dart.googlesource.com/external/github.com/flutter/flutter

cd flutter

bin/flutter config --no-analytics

pinned_dart_sdk=$(cat bin/cache/dart-sdk/revision)
patch=$checkout/tools/patches/flutter-engine/${pinned_dart_sdk}.flutter.patch
if [ -e "$patch" ]; then
  git apply $patch
fi

bin/flutter update-packages

# Analyze the flutter/flutter source code.
$dart --enable-asserts dev/bots/analyze.dart --dart-sdk $sdk

# Test flutter's use of data-driven fixes.
$dart fix packages/flutter/test_fixes --compare-to-golden

Remove duplicate flutter analyze snippets step from script
[infra] Remove duplicate flutter analyze snippets step from script

The snippets analyze step in [flutter]/dev/bots/analyze.dart now uses our built SDK when analyzing the code snippets. The explicit duplicate command to analyze the snippets with our SDK can now be removed.

The temp directory created in the script is not in the builder cache
on swarming, so it is automatically deleted when the builder finishes.
So we remove the cleanup step, which was trapping signals. That trap
seems to have been responsible for these failures and exit code confusion.

Bug: https://github.com/dart-lang/sdk/issues/47881
Change-Id: I49406954af54a0fba1ceec230c3551f8ad14e8e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226685
Reviewed-by: Paul Berry <72d414e3a99fb120308437779d51667bcc0984eb@google.com>
