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

Fix CLI --version test to use version from the binary not package.json #626

Merged
merged 1 commit into from
Jun 10, 2022

Conversation

cameel
Copy link
Member

@cameel cameel commented May 19, 2022

Currently tests in cli.ts are hard-coded to require a binary with version matching package.json. This not true in general and causes problems in #598.

This PR changes the test to only require the output from --version to match the output of version() function in the binary. I also kept a modified version of the previous check as a sanity check - to match that the output actually looks like our version string.

@cameel cameel self-assigned this May 19, 2022
@cameel cameel force-pushed the fix-version-test-dont-compare-with-package-json branch from 2134a08 to 529c2db Compare May 19, 2022 19:49

tape('CLI', function (t) {
t.test('--version', function (st) {
const spt = spawn(st, './solc.js --version');
spt.stdout.match(RegExp(pkg.version + '(-[^a-zA-A0-9.+]+)?(\\+[^a-zA-Z0-9.-]+)?'));
Copy link
Member Author

@cameel cameel May 19, 2022

Choose a reason for hiding this comment

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

This old regex actually seems very broken. Given that the string it's meant to match is something like 0.8.10+commit.fc410830.Emscripten.clang:

  • A-A should probably have been A-Z.
  • The character groups should not be negated with ^.
  • pkg.version contains dots, which are interpreted as any character, not literal dots.

I think that only reason this regex "worked" is that these broken parts are marked as optional (?) and the regex was not anchored with ^ and $. So really anything after the version was being accepted.

@cameel cameel force-pushed the fix-version-test-dont-compare-with-package-json branch from 529c2db to e078067 Compare May 19, 2022 19:56
@coveralls
Copy link

coveralls commented May 19, 2022

Coverage Status

Coverage remained the same at 83.721% when pulling 9a16f3d on fix-version-test-dont-compare-with-package-json into 3c2ed50 on master.

@cameel cameel force-pushed the fix-version-test-dont-compare-with-package-json branch from e078067 to 9a16f3d Compare June 10, 2022 18:23
@cameel cameel merged commit a9f1a58 into master Jun 10, 2022
@cameel cameel deleted the fix-version-test-dont-compare-with-package-json branch June 10, 2022 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants