Skip to content

fix(chromedriver): use chromedriver patch version as semver pre-release version #498

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/binaries/chrome_xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ export class ChromeXml extends XmlConfigSource {
* Chromedriver is the only binary that does not conform to semantic versioning
* and either has too little number of digits or too many. To get this to be in
* semver, we will either add a '.0' at the end or chop off the last set of
* digits. This is so we can compare to find the latest and greatest.
* digits (the patch number) and use it as a pre-release version. This is so we
* can compare to find the latest and greatest.
*
* Example:
* 2.46 -> 2.46.0
* 75.0.3770.8 -> 75.0.3770
* 75.0.3770.8 -> 75.0.3770-patch.8
*
* @param version
*/
Expand All @@ -151,10 +152,10 @@ export function getValidSemver(version: string): string {
}
// This supports downloading 74.0.3729.6
try {
const newRegex = /(\d+.\d+.\d+).\d+/g;
const newRegex = /(\d+.\d+.\d+).(\d+)/g;
const exec = newRegex.exec(version);
if (exec) {
lookUpVersion = exec[1];
lookUpVersion = `${exec[1]}-patch.${exec[2]}`;
}
} catch (_) {
// no-op: if this does not work, use the other regex pattern.
Expand Down
2 changes: 1 addition & 1 deletion lib/cmds/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function status(options: Options) {
if (semver.gt(a, b)) {
return 1;
} else {
return 0;
return -1;
Copy link
Author

@andrevechina andrevechina Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small fix on displaying versions sorted.

}
});
for (let ver in downloaded.versions) {
Expand Down
11 changes: 11 additions & 0 deletions spec/binaries/chrome_xml_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,15 @@ describe('chrome xml reader', () => {
done();
});
});

it('should get the 91.0.4472.101, 64-bit, m1 version (arch = arm64)', (done) => {
let chromeXml = new ChromeXml();
chromeXml.out_dir = out_dir;
chromeXml.ostype = 'Darwin';
chromeXml.osarch = 'arm64';
chromeXml.getUrl('91.0.4472.101').then((binaryUrl) => {
expect(binaryUrl.url).toContain('91.0.4472.101/chromedriver_mac64_m1.zip');
done();
});
});
});
2 changes: 1 addition & 1 deletion spec/cmds/status_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('status', () => {
.catch(err => {
done.fail();
});
});
}, 30000);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running update twice sometimes was taking more than Jasmine's default timeout (5s).
Updating this timeout to 30s made this test suite a lot more stable.


it('should show the version number of the default and latest versions', () => {
let lines =
Expand Down