-
Notifications
You must be signed in to change notification settings - Fork 126
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
Auto-parse end2end tests #1507
Auto-parse end2end tests #1507
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1507 +/- ##
==========================================
- Coverage 91.93% 91.92% -0.01%
==========================================
Files 680 680
Lines 24524 24533 +9
==========================================
+ Hits 22545 22553 +8
- Misses 1979 1980 +1
☔ View full report in Codecov by Sentry. |
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 start!
I have one design change that I hope to discuss with you.
Currently in this PR, we rely on the directory naming to figure out the test suite name and dataset path, which is fine, but limits the organization of test files, and coupling the directory name with test semantic is not a clean design in my mind. I think it's better to just have one file under the root level directory (tinysnb
, npy_1d
, etc.) that documents test suite name and dataset path.
You can see the first example in my proposal document. Let me know what do you think, we can discuss what's a better way.
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.
Also, I noticed one thing, when I actually run tests, I see message like this "TinysnbTest.Agg # GetParam() = Agg". Do you have any ideas why we have # GetParam() = Agg
?
Thank you @ray6080 for the valuable feedback! |
I realize I'm setting |
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.
LGTM. Please squash before you merge. Thanks!
test/test_helper/test_helper.cpp
Outdated
std::string line; | ||
while (getline(ifs, line)) { | ||
if (line.starts_with("-GROUP")) { | ||
result.testGroup = line.substr(7, line.length()); |
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.
Can you trim whitespaces after calling substr
? I think it's better to guard against whitespaces in group names.
Same for the following if cases.
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.
Added setConfigValue
to solve this.
Once I start working on the test file parser, I was thinking of improving this parser by separating it into other classes and having better validation. I'll share more specifics soon.
test/runner/e2e_read_test.cpp
Outdated
TestConfig testConfig; | ||
std::vector<TestConfig> tests; | ||
std::string previousDirectory; | ||
for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) { |
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.
I'm not familiar with recursive_directory_iterator
. Just one question here: I guess recursive_directory_iterator
have the iteration order guarantee? It seems you rely on that as you are checking FileUtils::getParentPathStem(entry) != previousDirectory
. Specifically, I just want to make sure that the following case is covered in this function.
test_files/test.group
test_files/t1.test
test_files/group1/test.group
test_files/group1/g1.test
test_files/group2/case1/test.group
test_files/group2/case1/g2c1.test
Alternatively, I think something like the following also makes sense, if you don't want to rely on the recursive_directory_iterator
:
void scanTestFiles(const std::string& path, std::vector<TestConfig>& configs) {
for (entry in path) {
if (test group file exists) {
auto config = parseTestGroup(path);
if (config.isValid()) {
configs.push_back(config);
}
}
if (entry is directory) { scanTestFiles(entry.path, configs); }
}
}
TestConfig parseTestGroup(const std::string& path) {
auto testConfig = TestHelper::parseGroupFile(testGroupFile);
for (entry in path) {
if (entry is a file && entry's extension is ".test") {
testConfig.files.push_back(entry.path().string());
}
}
return testConfig;
}
Your call here. I don't have preferences over these two solutions.
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.
Thanks, that's a good point.
From my tests, I haven't seen something like this (which will result in failure):
test_files/group2/case1/test.group
test_files/group1/g1.test
test_files/group2/case1/g2c1.test
However, looking at the documentation, it seems the order is not guaranteed.
Your solution is more reliable and clear, I'll implement that.
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.
I initially implemented your code, the only necessary change was to add a bool to check if the current directory was processed and not create multiple configs. It worked, but I slightly changed it to check the directories first and then parse them. I believe it's cleaner, the functions are very small. I hope you're ok with that.
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.
Sure! LGTM!
Initial proposal to scan end to end files inside e2e directory and dynamically run the tests.
An initial proposal to scan end-to-end files inside the e2e directory and dynamically run the tests.
This PR is related to the first task in the proposal TODO list:
How to add new end-to-end tests
For each e2e test, create a file named "test.group" containing the following fields:
Implementation details
e2e_read_test
recursively scan for.test
files insidetest/test_files
test.group
, parse the file and extract the necessary information to create the tests dynamicallyREAD_ONLY
is in the test_files, it's been used only for informative purposes