@@ -48,6 +48,64 @@ Future<void> main() async {
48
48
expect (stdout, contains ('Successfully received SIGTERM!' ));
49
49
},
50
50
skip: platform.isWindows); // [intended] Windows does not use the bash entrypoint
51
+
52
+ test ('shared.sh does not compile flutter tool if PROG_NAME=dart' , () async {
53
+ final Directory tempDir = fileSystem.systemTempDirectory.createTempSync ('bash_entrypoint_test' );
54
+ try {
55
+ // bash script checks it is in a git repo
56
+ ProcessResult result = await processManager.run (< String > ['git' , 'init' ], workingDirectory: tempDir.path);
57
+ expect (result, const ProcessResultMatcher ());
58
+ result = await processManager.run (< String > ['git' , 'commit' , '--allow-empty' , '-m' , 'init commit' ], workingDirectory: tempDir.path);
59
+ expect (result, const ProcessResultMatcher ());
60
+
61
+ // copy dart and shared.sh to temp dir
62
+ final File trueSharedSh = flutterRoot.childDirectory ('bin' ).childDirectory ('internal' ).childFile ('shared.sh' );
63
+ final File fakeSharedSh = (tempDir.childDirectory ('bin' ).childDirectory ('internal' )
64
+ ..createSync (recursive: true ))
65
+ .childFile ('shared.sh' );
66
+ trueSharedSh.copySync (fakeSharedSh.path);
67
+ final File fakeDartBash = tempDir.childDirectory ('bin' ).childFile ('dart' );
68
+ dartBash.copySync (fakeDartBash.path);
69
+ // mark dart executable
70
+ makeExecutable (fakeDartBash);
71
+
72
+ // create no-op fake update_dart_sdk.sh script
73
+ final File updateDartSdk = tempDir.childDirectory ('bin' ).childDirectory ('internal' ).childFile ('update_dart_sdk.sh' )..writeAsStringSync ('''
74
+ #!/usr/bin/env bash
75
+
76
+ echo downloaded dart sdk
77
+ ''' );
78
+ makeExecutable (updateDartSdk);
79
+
80
+ // create a fake dart runtime
81
+ final File dartBin = (tempDir.childDirectory ('bin' )
82
+ .childDirectory ('cache' )
83
+ .childDirectory ('dart-sdk' )
84
+ .childDirectory ('bin' )
85
+ ..createSync (recursive: true ))
86
+ .childFile ('dart' );
87
+ dartBin.writeAsStringSync ('''
88
+ #!/usr/bin/env bash
89
+
90
+ echo executed dart binary
91
+ ''' );
92
+ makeExecutable (dartBin);
93
+
94
+ result = await processManager.run (< String > [fakeDartBash.path]);
95
+ expect (result, const ProcessResultMatcher ());
96
+ expect (
97
+ (result.stdout as String ).split ('\n ' ),
98
+ // verify we ran updateDartSdk and dartBin
99
+ containsAll (< String > ['downloaded dart sdk' , 'executed dart binary' ]),
100
+ );
101
+
102
+ // Verify we did not try to compile the flutter_tool
103
+ expect (result.stderr, isNot (contains ('Building flutter tool...' )));
104
+ } finally {
105
+ tryToDelete (tempDir);
106
+ }
107
+ },
108
+ skip: platform.isWindows); // [intended] Windows does not use the bash entrypoint
51
109
}
52
110
53
111
// A test Dart app that will run until it receives SIGTERM
@@ -69,3 +127,8 @@ File get dartBash {
69
127
.childFile ('dart' )
70
128
.absolute;
71
129
}
130
+
131
+ void makeExecutable (File file) {
132
+ final ProcessResult result = processManager.runSync (< String > ['chmod' , '+x' , file.path]);
133
+ expect (result, const ProcessResultMatcher ());
134
+ }
0 commit comments