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

Infer test group name directly from test file path #3418

Merged
merged 10 commits into from
May 3, 2024

Conversation

yiyun-sj
Copy link
Collaborator

@yiyun-sj yiyun-sj commented Apr 30, 2024

Test Group Name Generation

  • uses the relative file path as test group name
  • delimiter choice is '~' ('.' is reserved by gtest, '/' is reserved by file path)
  • current -GROUP property is not removed for backward compatibility (is this necessary?)

Note: some characters such as : and - result in tests not being actually run (some current test cases are like this)
image

Example
the file test/test_files/tck/match/match8 now has test group name tck~match~match8

Todo
delete -GROUP from all existing test files (do we want to do this?)

@yiyun-sj yiyun-sj linked an issue Apr 30, 2024 that may be closed by this pull request
@yiyun-sj yiyun-sj marked this pull request as ready for review May 1, 2024 15:47
@yiyun-sj yiyun-sj requested a review from ray6080 May 1, 2024 15:48
Copy link
Contributor

@ray6080 ray6080 left a comment

Choose a reason for hiding this comment

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

LGTM. Let's bring this to the team for some feedback too. We shall make this as the new convention.

@@ -67,8 +79,6 @@ void TestParser::parseHeader() {
break;
}
case TokenType::GROUP: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need TokenType::GROUP?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept it in for the sake of backward compatibility. We can remove it if we want to.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove it then.

std::size_t subEnd = path.find_last_of('.') - 1;
std::string relPath = path.substr(subStart, subEnd - subStart + 1);
std::replace(relPath.begin(), relPath.end(), '-', '_');
std::replace(relPath.begin(), relPath.end(), '/', '|');
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm will this replace work on windows?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added another replace line for windows backslash. Also had to change delimiter since windows does not support |

1;
std::size_t subEnd = path.find_last_of('.') - 1;
std::string relPath = path.substr(subStart, subEnd - subStart + 1);
std::replace(relPath.begin(), relPath.end(), '-', '_');
Copy link
Contributor

@ray6080 ray6080 May 2, 2024

Choose a reason for hiding this comment

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

I don't think we should replace - with _. Users of the testing framework should follow the convention of using _ instead of - in file/dir names themselves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did this as a workaround as a bunch of files/directories had - in the codebase which results in a false positive during the test runs. I could also go and change those files and remove this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do u mean "false positive" here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed this line and fixed the naming of existing tests

Copy link
Contributor

@ray6080 ray6080 left a comment

Choose a reason for hiding this comment

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

Can u also update the docs now regarding to the changes on test group name?

@@ -67,8 +79,6 @@ void TestParser::parseHeader() {
break;
}
case TokenType::GROUP: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove it then.

@ray6080
Copy link
Contributor

ray6080 commented May 3, 2024

Also, can u revisit the false positive issue? We'd better understand what's acceptable directory and file naming conventions under test_files.

@yiyun-sj yiyun-sj merged commit 66baf43 into master May 3, 2024
17 checks passed
@yiyun-sj yiyun-sj deleted the test-group-generation branch May 3, 2024 21:12
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.

Testing framework improvement
2 participants