-
Notifications
You must be signed in to change notification settings - Fork 12
Test for ini parsing (python and C) #116
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
base: main
Are you sure you want to change the base?
Conversation
3fb0d16 to
6922ca0
Compare
- Check values from default.ini - Check values from drive.ini - Additional checks for comments capabilities
- Add CMake project to configure, build and test - Test value parsing - Test comments format - Add comments for (un)expected results
- Compile with asan
- Ini parsing tests - Update comments to clarify intent
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.
Pull Request Overview
This PR adds comprehensive test coverage for INI file parsing in both Python and C. The tests verify that the configuration loading functionality correctly parses INI files, handles comments, and supports command-line overrides.
Key changes:
- Added Python unit tests for INI configuration loading with various test scenarios
- Added C-based tests using the inih library to verify INI parsing behavior
- Created GitHub Actions workflow to run both Python and C tests
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_drive_config.py | Python unit tests for configuration loading, comment handling, and CLI overrides |
| tests/ini_parser/test_drive.ini | Test INI file with various configurations and comment styles |
| tests/ini_parser/ini_tester.c | C test implementation using inih library to verify parsing behavior |
| tests/ini_parser/build_n_test.sh | Build script for compiling and running C tests |
| tests/ini_parser/CMakeLists.txt | CMake configuration for building C test executable |
| .github/workflows/utest.yml | GitHub Actions workflow to run both Python and C tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } if (MATCH("env", "action_type")) { | ||
| env_config->action_type = strdup(value); | ||
| } if (MATCH("env", "num_maps")) { | ||
| env_config->num_maps = atoi(value); | ||
| } if (MATCH("policy", "input_size")) { | ||
| env_config->input_size = atoi(value); | ||
| } if (MATCH("policy", "hidden_size")) { | ||
| env_config->hidden_size = atoi(value); | ||
| } if (MATCH("test", "key1")) { | ||
| env_config->key1 = atoi(value); | ||
| } if (MATCH("test", "key2")) { | ||
| env_config->key2 = atof(value); | ||
| } if (MATCH("test", "key3")) { | ||
| env_config->key3 = atoi(value); | ||
| } if (MATCH("test", "key31")) { | ||
| env_config->key3 = atof(value); | ||
| } if (MATCH("test", "key4")) { | ||
| env_config->key4 = strdup(value); | ||
| } if (MATCH("test", "key5")) { | ||
| env_config->key5 = strdup(value); | ||
| } if (MATCH("test", "key6")) { | ||
| env_config->key6 = atoi(value); | ||
| } if (MATCH("test", "key7")) { |
Copilot
AI
Nov 10, 2025
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.
All the if statements from lines 37-60 should be 'else if' statements. Currently, the logic continues checking all conditions even after finding a match, and the final 'else' block at line 61 only applies to the last 'if' statement (key7), not to the entire chain as intended. This means unmatched keys will incorrectly return 1 instead of 0.
| } if (MATCH("env", "action_type")) { | |
| env_config->action_type = strdup(value); | |
| } if (MATCH("env", "num_maps")) { | |
| env_config->num_maps = atoi(value); | |
| } if (MATCH("policy", "input_size")) { | |
| env_config->input_size = atoi(value); | |
| } if (MATCH("policy", "hidden_size")) { | |
| env_config->hidden_size = atoi(value); | |
| } if (MATCH("test", "key1")) { | |
| env_config->key1 = atoi(value); | |
| } if (MATCH("test", "key2")) { | |
| env_config->key2 = atof(value); | |
| } if (MATCH("test", "key3")) { | |
| env_config->key3 = atoi(value); | |
| } if (MATCH("test", "key31")) { | |
| env_config->key3 = atof(value); | |
| } if (MATCH("test", "key4")) { | |
| env_config->key4 = strdup(value); | |
| } if (MATCH("test", "key5")) { | |
| env_config->key5 = strdup(value); | |
| } if (MATCH("test", "key6")) { | |
| env_config->key6 = atoi(value); | |
| } if (MATCH("test", "key7")) { | |
| } else if (MATCH("env", "action_type")) { | |
| env_config->action_type = strdup(value); | |
| } else if (MATCH("env", "num_maps")) { | |
| env_config->num_maps = atoi(value); | |
| } else if (MATCH("policy", "input_size")) { | |
| env_config->input_size = atoi(value); | |
| } else if (MATCH("policy", "hidden_size")) { | |
| env_config->hidden_size = atoi(value); | |
| } else if (MATCH("test", "key1")) { | |
| env_config->key1 = atoi(value); | |
| } else if (MATCH("test", "key2")) { | |
| env_config->key2 = atof(value); | |
| } else if (MATCH("test", "key3")) { | |
| env_config->key3 = atoi(value); | |
| } else if (MATCH("test", "key31")) { | |
| env_config->key3 = atof(value); | |
| } else if (MATCH("test", "key4")) { | |
| env_config->key4 = strdup(value); | |
| } else if (MATCH("test", "key5")) { | |
| env_config->key5 = strdup(value); | |
| } else if (MATCH("test", "key6")) { | |
| env_config->key6 = atoi(value); | |
| } else if (MATCH("test", "key7")) { |
| } if (MATCH("test", "key3")) { | ||
| env_config->key3 = atoi(value); | ||
| } if (MATCH("test", "key31")) { | ||
| env_config->key3 = atof(value); |
Copilot
AI
Nov 10, 2025
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.
This should assign to 'env_config->key31' instead of 'env_config->key3'. The current code incorrectly overwrites key3 when key31 is parsed.
| env_config->key3 = atof(value); | |
| env_config->key31 = atof(value); |
Add tests for INI parsing.