forked from smartdevicelink/sdl_evolution
-
Notifications
You must be signed in to change notification settings - Fork 1
Proposal for "Refactoring of Common Modules" #1
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
Open
dboltovskyi
wants to merge
6
commits into
master
Choose a base branch
from
test_scripts_common_modules_refactoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a6f3f5b
Initial version
dboltovskyi 7fb7bc7
Update
dboltovskyi e932de8
Update according to comments in review
dboltovskyi 2e83ef6
Update NNNN-test-scripts-common-modules-refactoring.md
dboltovskyi 6d721f6
Update NNNN-test-scripts-common-modules-refactoring.md
dboltovskyi d024b86
Update NNNN-test-scripts-common-modules-refactoring.md
dboltovskyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Test Scripts - Refactoring of Common modules | ||
|
||
* Proposal: [SDL-NNNN](NNNN-test-scripts-common-modules-refactoring.md) | ||
* Author: [Dmytro Boltovskyi](https://github.com/dboltovskyi) | ||
* Status: **Awaiting review** | ||
* Impacted Platforms: [ATF] | ||
|
||
## Introduction | ||
|
||
[ATF test scripts](https://github.com/smartdevicelink/sdl_atf_test_scripts/) use a lot of functions in commonly used modules, like: | ||
|
||
- data accessors: file, database | ||
- functions for tables: print, copy | ||
- sequences: | ||
- create mobile session | ||
- register/activate mobile application | ||
- perform policy table update | ||
- etc. | ||
|
||
All these functionality are not tests artifacts but tools that tests use. | ||
|
||
The purpose of this proposal is to clean up these common modules that everyone is able to use while creating ATF test scripts. | ||
|
||
## Motivation | ||
|
||
Current downsides of common modules are: | ||
|
||
- There is no clear structure | ||
- Lack of description for huge amount of functions | ||
- There is no single standard for the functions | ||
- Some functions are duplicated | ||
- A lot of outdated and unused code | ||
|
||
## Proposed solution | ||
|
||
In order to clean up the common modules there are following items needs to be done. | ||
|
||
### Leave existing modules as is for backward compatibility | ||
|
||
By leaving all existing modules currently located in ./user_modules folder as is | ||
it will be possible to use all existing ATF test scripts without changes. | ||
|
||
### Design a standard template for functions | ||
|
||
Each function in common modules should follow a template. E.g.: | ||
|
||
```lua | ||
--[[ @jsonFileToTable: convert .json file to table | ||
--! @parameters: | ||
--! pFileName - input file name | ||
--! @return: table with data | ||
--]] | ||
local function jsonFileToTable(pFileName) | ||
local f = io.open(pFileName, "r") | ||
local content = f:read("*all") | ||
f:close() | ||
return json.decode(content) | ||
end | ||
``` | ||
|
||
### Create new folders structure | ||
|
||
In test scripts repository create the following folders structure: | ||
|
||
``` | ||
./common_modules/ | ||
utils/ | ||
sequences/ | ||
``` | ||
|
||
- utils - folder for modules with utility functions (e.g.: data accessors, table functions, data converters, etc.) | ||
- sequences - folder for modules with common sequences (e.g.: register/activate mobile application, policy update, put file, etc.) | ||
|
||
### Transfer most used common functions into a new folder | ||
|
||
Most used functions need to be transferred from existing "user_modules" to a new "common_modules" folder in appropriate module file. | ||
Also they need to be updated according to a new template. | ||
A few functions can be placed in one module file. | ||
|
||
### Follow new approach when developing new ATF test scripts | ||
|
||
- In newly created ATF scripts use only functions from new "common_modules" folder and not from an old "user_modules" one | ||
- If some utility or common sequence function doesn't exist - create it in a new "common_modules" in appropriate module file using standard template | ||
|
||
## Potential downsides | ||
|
||
Existing ATF test scripts must be updated if some function from new common modules is required. | ||
|
||
## Impact on existing code | ||
|
||
Since new common modules is going to be implemented in a new separate folder there will be no impact on existing code. | ||
|
||
## Alternatives considered | ||
|
||
Use current approach. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@dboltovskyi standart
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.
@dboltovskyi You are right. Correct word is
STANDARD