-
Notifications
You must be signed in to change notification settings - Fork 143
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
feat: adding gradlew version to the doctor output #2255
Changes from 9 commits
562c905
f6f50f0
eb302ae
0773648
043833b
c0a19f8
09d378a
aca166c
a322964
dac8f13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,13 +76,13 @@ Make sure you have run "flutter build apk" at least once.''', | |
}); | ||
}); | ||
|
||
group('productFlavors', () { | ||
Directory setUpAppTempDir() { | ||
final tempDir = Directory.systemTemp.createTempSync(); | ||
Directory(p.join(tempDir.path, 'android')).createSync(recursive: true); | ||
return tempDir; | ||
} | ||
Directory setUpAppTempDir() { | ||
final tempDir = Directory.systemTemp.createTempSync(); | ||
Directory(p.join(tempDir.path, 'android')).createSync(recursive: true); | ||
return tempDir; | ||
} | ||
|
||
group('productFlavors', () { | ||
test( | ||
'throws MissingAndroidProjectException ' | ||
'when android root does not exist', () async { | ||
|
@@ -329,5 +329,110 @@ Make sure you have run "flutter build apk" at least once.''', | |
}, | ||
); | ||
}); | ||
|
||
group('exists', () { | ||
late Directory tempDir; | ||
setUp(() { | ||
tempDir = setUpAppTempDir(); | ||
}); | ||
|
||
group('when gradlew does not exist', () { | ||
test('returns false', () { | ||
expect(gradlew.exists(tempDir.path), isFalse); | ||
}); | ||
}); | ||
|
||
group('when gradlew exists', () { | ||
group( | ||
'when on unix based OSs', | ||
() { | ||
setUp(() { | ||
File( | ||
p.join(tempDir.path, 'android', 'gradlew'), | ||
).createSync(recursive: true); | ||
erickzanardo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test( | ||
'returns true', | ||
() { | ||
expect(gradlew.exists(tempDir.path), isTrue); | ||
}, | ||
testOn: 'linux || mac-os', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat, I didn't know There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, me neither, I just learned. Apparently |
||
); | ||
}, | ||
); | ||
|
||
group( | ||
'when on windows', | ||
() { | ||
setUp(() { | ||
File( | ||
p.join(tempDir.path, 'android', 'gradlew.bat'), | ||
).createSync(recursive: true); | ||
erickzanardo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test( | ||
'returns true', | ||
() { | ||
expect(gradlew.exists(tempDir.path), isTrue); | ||
}, | ||
testOn: 'windows', | ||
); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
group('version', () { | ||
late Directory tempDir; | ||
|
||
setUp(() { | ||
when(() => platform.isLinux).thenReturn(true); | ||
when(() => platform.isMacOS).thenReturn(false); | ||
when(() => platform.isWindows).thenReturn(false); | ||
erickzanardo marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here re: testOn There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one I am not sure if it is worth to run in all platforms, since all is being tested is the parsing of the output, which shouldn't change (at least the relevant part for us), no matter which platform we are. And if I change to testOn, then I will need to write one test for each platform (or at least of for unix based and one for windows), because we need to mock the executable (which you can see a couple of lines above) path differently. Lmk if this makes sense There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to write one for each platform. I'm just suggesting that we use a consistent method of targeting a platform for a test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, changed to use |
||
tempDir = setUpAppTempDir(); | ||
File( | ||
p.join(tempDir.path, 'android', 'gradlew'), | ||
).createSync(recursive: true); | ||
const javaHome = 'test_java_home'; | ||
when(() => platform.environment).thenReturn({'JAVA_HOME': javaHome}); | ||
|
||
when(() => result.stdout).thenReturn(''' | ||
|
||
------------------------------------------------------------ | ||
Gradle 7.6.3 | ||
------------------------------------------------------------ | ||
|
||
Build time: 2023-10-04 15:59:47 UTC | ||
Revision: 1694251d59e0d4752d547e1fd5b5020b798a7e71 | ||
|
||
Kotlin: 1.7.10 | ||
Groovy: 3.0.13 | ||
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 | ||
JVM: 11.0.23 (Azul Systems, Inc. 11.0.23+9-LTS) | ||
OS: Mac OS X 14.4.1 aarch64 | ||
'''); | ||
}); | ||
|
||
test('returns the correct version', () async { | ||
final version = await runWithOverrides( | ||
() => gradlew.version(tempDir.path), | ||
); | ||
expect(version, '7.6.3'); | ||
}); | ||
|
||
group('when the output cannot be parsed', () { | ||
setUp(() { | ||
when(() => result.stdout).thenReturn('not a real version'); | ||
}); | ||
|
||
test('returns unknown', () async { | ||
final version = await runWithOverrides( | ||
() => gradlew.version(tempDir.path), | ||
); | ||
expect(version, 'unknown'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!