1. Add `PortScanner` abstraction so that we don't do actual port scanning
in tests.
2. Don't change the real `cwd` of the isolate during tests, as it affects
all tests, not just the current running test.
Fixes#8761
This updates the flutter analyze command to use the .analysis_options_flutter_analyze in the repo root when either the --flutter-repo flag is supplied or the sources being analyzed reside in the flutter repo.