Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using flutter create to repair a project with the --empty option deletes test folder #134928

Open
2 tasks done
lucavenir opened this issue Sep 18, 2023 · 7 comments · May be fixed by #147160
Open
2 tasks done

Using flutter create to repair a project with the --empty option deletes test folder #134928

lucavenir opened this issue Sep 18, 2023 · 7 comments · May be fixed by #147160
Labels
found in release: 3.13 Found to occur in 3.13 found in release: 3.14 Found to occur in 3.14 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@lucavenir
Copy link

lucavenir commented Sep 18, 2023

Is there an existing issue for this?

Steps to reproduce

Run the following commands sequentially:

flutter create my_app --empty
mkdir my_app/test
touch my_app/test/some_test.dart
cat my_app/test/some_test.dart  # prints nothing, finds this file
flutter create my_app --empty  # I want to repair this project, but I don't want to add any boilerplate
cat my_app/test/some_test.dart  # ! No such file or directory

Expected results

some_test.dart shouldn't be deleted since we are just trying to repair this project after its initial creation.

Actual results

The whole test folder is now gone.

Alternatives I've considered

Using flutter create without the --empty option. But that'll add the boilerplate I want to avoid.

Context

I'm trying to set-up my own mason brick, with several files in both lib and test which. flutter create . --empty is handy since it won't generate useless (within this context) files.

Code sample

N.A.

Screenshots or Video

N.A.

Logs

N.A.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.13.2, on Ubuntu 22.04.3 LTS 6.2.0-32-generic, locale en_US.UTF-8)
    • Flutter version 3.13.2 on channel stable at /home/venir/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (4 weeks ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /home/venir/Android/Sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 18.0.2-ea+9-Ubuntu-222.04)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] VS Code (version unknown)
    • VS Code at /snap/code/current
    • Flutter extension version 3.72.0
    ✗ Unable to determine VS Code version.

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.3 LTS 6.2.0-32-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 117.0.5938.62

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Sep 19, 2023
@darshankawar
Copy link
Member

Thanks for the report @lucavenir
I followed the steps to replicate the reported behavior but getting below:

dhs@Dhss-MacBook-Pro ncflutter % touch my_test_app/test/some_test.dart
touch: my_test_app/test/some_test.dart: No such file or directory
dhs@Dhss-MacBook-Pro ncflutter % 

ie, while trying to run touch to create some_test.dart, it doesn't seem to create the said file and shows the message no such file or directory.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 19, 2023
@lucavenir
Copy link
Author

lucavenir commented Sep 19, 2023

I updated the steps: I forgot to let you create the test folder, first 😄

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 19, 2023
@darshankawar
Copy link
Member

Thanks for the update. I followed the updated steps but don't seem to replicate the reported behavior. See below for the steps taken:

dhs@Dhss-MacBook-Pro my_test_app % ls
README.md		lib			pubspec.lock
analysis_options.yaml	linux			pubspec.yaml
android			macos			web
ios			my_test_app.iml		windows
dhs@Dhss-MacBook-Pro my_test_app % mkdir my_test_app/test
mkdir: my_test_app: No such file or directory
dhs@Dhss-MacBook-Pro my_test_app % mkdir test
dhs@Dhss-MacBook-Pro my_test_app % ls
README.md		linux			test
analysis_options.yaml	macos			web
android			my_test_app.iml		windows
ios			pubspec.lock
lib			pubspec.yaml
dhs@Dhss-MacBook-Pro my_test_app % touch my_app_test/test/some_test.dart
touch: my_app_test/test/some_test.dart: No such file or directory
dhs@Dhss-MacBook-Pro my_test_app % cd test
dhs@Dhss-MacBook-Pro test % touch some_test.dart
dhs@Dhss-MacBook-Pro test % ls
some_test.dart
dhs@Dhss-MacBook-Pro test % cat some_test.dart
dhs@Dhss-MacBook-Pro test % cd ..  
dhs@Dhss-MacBook-Pro my_test_app % flutter create my_test_app --empty
Signing iOS app for device deployment using developer identity: "Apple
Development: Darshan Kawar (AV76JL68FU)"
Creating project my_test_app...
Resolving dependencies in my_test_app... (1.6s)
Got dependencies in my_test_app.
Wrote 128 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider:
https://www.youtube.com/c/flutterdev

In order to run your empty application, type:

  $ cd my_test_app
  $ flutter run

Your empty application code is in my_test_app/lib/main.dart.

dhs@Dhss-MacBook-Pro my_test_app % cat my_test_app/test/some_test.dart
cat: my_test_app/test/some_test.dart: No such file or directory
dhs@Dhss-MacBook-Pro my_test_app % ls
README.md		linux			pubspec.yaml
analysis_options.yaml	macos			test
android			my_test_app		web
ios			my_test_app.iml		windows
lib			pubspec.lock
dhs@Dhss-MacBook-Pro my_test_app % cd test
dhs@Dhss-MacBook-Pro test % ls
some_test.dart
dhs@Dhss-MacBook-Pro test % cd

If you see the last section above, it does seem to have test folder and underlying some_test.dart file.

dhs@Dhss-MacBook-Pro my_test_app % cd test
dhs@Dhss-MacBook-Pro test % ls
some_test.dart
dhs@Dhss-MacBook-Pro test % cd

I tried above using latest master version.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 19, 2023
@lucavenir
Copy link
Author

I switched to the master channel just to be sure: let's try this again.
Here's my output - and again, same steps above (copy / pasted into my terminal):

venir@venir:~$ flutter create my_app --empty
mkdir my_app/test
touch my_app/test/some_test.dart
cat my_app/test/some_test.dart  # prints nothing, finds this file
flutter create my_app --empty  # I want to repair this project, but I don't want to add any boilerplate
cat my_app/test/some_test.dart  # ! No such file or directory
Creating project my_app...
Resolving dependencies in my_app... (2.8s)
Got dependencies in my_app.
Wrote 128 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev

In order to run your empty application, type:

  $ cd my_app
  $ flutter run

Your empty application code is in my_app/lib/main.dart.

Recreating project my_app...
  my_app/test/widget_test.dart (created)
Resolving dependencies in my_app... 
Got dependencies in my_app.
Wrote 2 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev

In order to run your empty application, type:

  $ cd my_app
  $ flutter run

Your empty application code is in my_app/lib/main.dart.

cat: my_app/test/some_test.dart: No such file or directory  # !!

I do receive the error. I'm not using MacOs, this is Linux tho.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 19, 2023
@darshankawar
Copy link
Member

Thanks for the update. I do see the same behavior as reported now.

dhs@Dhss-MacBook-Pro ncflutter % flutter create another_app --empty
Signing iOS app for device deployment using developer identity: "Apple
Development: Darshan Kawar (AV76JL68FU)"
Creating project another_app...
Resolving dependencies in another_app... (1.9s)
Got dependencies in another_app.
Wrote 128 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider:
https://www.youtube.com/c/flutterdev

In order to run your empty application, type:

  $ cd another_app
  $ flutter run

Your empty application code is in another_app/lib/main.dart.

dhs@Dhss-MacBook-Pro ncflutter % cd another_app
dhs@Dhss-MacBook-Pro another_app % mkdir test
dhs@Dhss-MacBook-Pro another_app % pwd  
/Users/dhs/documents/ncflutter/another_app
dhs@Dhss-MacBook-Pro another_app % ls
README.md		lib			test
analysis_options.yaml	linux			web
android			macos			windows
another_app.iml		pubspec.lock
ios			pubspec.yaml
dhs@Dhss-MacBook-Pro another_app % touch test/some_test.dart
dhs@Dhss-MacBook-Pro another_app % ls
README.md		lib			test
analysis_options.yaml	linux			web
android			macos			windows
another_app.iml		pubspec.lock
ios			pubspec.yaml
dhs@Dhss-MacBook-Pro another_app % cd test
dhs@Dhss-MacBook-Pro test % ls
some_test.dart
dhs@Dhss-MacBook-Pro test % cat some_test.dart
dhs@Dhss-MacBook-Pro test % cd ..
dhs@Dhss-MacBook-Pro another_app % cd ..                  
dhs@Dhss-MacBook-Pro ncflutter % flutter create another_app --empty
Signing iOS app for device deployment using developer identity: "Apple
Development: Darshan Kawar (AV76JL68FU)"
Recreating project another_app...
  another_app/test/widget_test.dart (created)
Resolving dependencies in another_app... 
Got dependencies in another_app.
Wrote 2 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider:
https://www.youtube.com/c/flutterdev

In order to run your empty application, type:

  $ cd another_app
  $ flutter run

Your empty application code is in another_app/lib/main.dart.

dhs@Dhss-MacBook-Pro ncflutter % cat another_app/test/some_test.dart
cat: another_app/test/some_test.dart: No such file or directory
dhs@Dhss-MacBook-Pro ncflutter % cd another_app
dhs@Dhss-MacBook-Pro another_app % ls
README.md		ios			pubspec.lock
analysis_options.yaml	lib			pubspec.yaml
android			linux			web
another_app.iml		macos			windows
dhs@Dhss-MacBook-Pro another_app % 
stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.13.4, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 3.13.4 on channel stable at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 367f9ea16b (6 days ago), 2023-09-12 23:27:53 -0500
    • Engine revision 9064459a8b
    • Dart version 3.1.2
    • DevTools version 2.25.0
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

[!] Flutter (Channel master, 3.14.0-14.0.pre.375, on macOS 12.2.1 21D62
    darwin-x64, locale en-GB)
    • Flutter version 3.14.0-14.0.pre.375 on channel master at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e300fda767 (20 minutes ago), 2023-09-20 00:51:11 -0400
    • Engine revision 81b93fc4a2
    • Dart version 3.2.0 (build 3.2.0-180.0.dev)
    • DevTools version 2.28.0-dev.8
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/dhs/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 65.1.4
    • Dart plugin version 213.7228

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (3 available)
    • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
      • iOS 15.3.1 19D52
    • macOS (desktop)           • macos                                    •
      darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)              • chrome                                   •
      web-javascript • Google Chrome 109.0.5414.119

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
      
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.



@darshankawar darshankawar added tool Affects the "flutter" command-line tool. See also t: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.13 Found to occur in 3.13 found in release: 3.14 Found to occur in 3.14 team-tool Owned by Flutter Tool team and removed in triage Presently being triaged by the triage team labels Sep 20, 2023
@christopherfujino christopherfujino added P2 Important issues not at the top of the work list triaged-tool Triaged by Flutter Tool team labels Sep 26, 2023
@victoreronmosele
Copy link
Contributor

I made a PR addressing this issue: #147160.

@andrewkolos
Copy link
Contributor

@gspencergoog Do you happen to recall why --empty deletes the test directory? Code here:

if (sampleCode != null) {
_applySample(relativeDir, sampleCode);
}
if (sampleCode != null || emptyArgument) {
generatedFileCount += _removeTestDir(relativeDir);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
found in release: 3.13 Found to occur in 3.13 found in release: 3.14 Found to occur in 3.14 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
None yet
5 participants