-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor existing tox test to pytest #24
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
Merged
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3848c50
Create file
7872835
Set up shared configurations
8c49bc1
Refactor test_run environment
16bbf4c
Refactor test_release environment
236dbb4
Fix folder name
fa16f3c
Add pytest in requirements.txt
9038838
Change file root
fed7a42
Fix empty line
3e0efc4
Fix empty line
ae4c22f
Fix unnecessary variable
500e3bd
Change pytest command
1e4f709
Fix run tox error
1188ed6
Fix ValueError
4d46b75
Fix FLAKE8 Error
b8622f3
Handle environment
d9b1a60
Handle CI environment
46a002a
Separate Enviroment by pytest marks
b098568
Add pytest command with release marker filtering
e990328
Delete pytest in requirements.txt
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 |
|---|---|---|
|
|
@@ -16,3 +16,4 @@ tqdm | |
| urlopen | ||
| XlsxWriter | ||
| PyYAML | ||
| pytest | ||
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,28 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf-8 -*- | ||
| # Android binary analysis script | ||
| # SPDX-FileCopyrightText: Copyright 2023 LG Electronics Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import os | ||
| import subprocess | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def android_src_path(): | ||
| return os.getenv("ANDROID_SRC_PATH") | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def android_build_log(): | ||
| return os.getenv("ANDROID_BUILD_LOG") | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def run_command(): | ||
| def _run_command(command): | ||
| result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| success = result.returncode == 0 | ||
| return success, result.stdout.decode('utf-8'), result.stderr.decode('utf-8') | ||
| return _run_command | ||
ena-isme marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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,44 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf-8 -*- | ||
| # Android binary analysis script | ||
| # SPDX-FileCopyrightText: Copyright 2023 LG Electronics Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
|
|
||
| import os | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.mark.run | ||
| def test_fosslight_android(run_command, android_src_path, android_build_log): | ||
|
|
||
| # given | ||
| assert android_src_path, "android_src_path is not set." | ||
| assert android_build_log, "android_build_log is not set." | ||
ena-isme marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # when | ||
| command = f"fosslight_android -s {android_src_path} -a {android_build_log} -m" | ||
| success, stdout, stderr = run_command(command) | ||
|
|
||
| # then | ||
| assert success is True, f"fosslight_android test_run failed. stderr: {stderr}" | ||
ena-isme marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| @pytest.mark.release | ||
| def test_release_environment(run_command): | ||
|
|
||
| # given | ||
| test_result, _, _ = run_command("rm -rf test_result") | ||
| os.makedirs("test_result", exist_ok=True) | ||
|
|
||
| # when | ||
| help_result, _, _ = run_command("fosslight_android -h") | ||
| ok_result, _, _ = run_command("fosslight_android -b test/binary.txt -n test/NOTICE.html -c ok") | ||
| nok_result, _, _ = run_command("fosslight_android -b test/binary.txt -n test/NOTICE.html -c nok") | ||
| divide_result, _, _ = run_command("fosslight_android -d test/needtoadd-notice.html") | ||
|
|
||
| # then | ||
| assert help_result is True, "Help command failed" | ||
| assert ok_result is True, "OK command failed" | ||
| assert nok_result is True, "NOK command failed" | ||
| assert divide_result is True, "Divide command failed" | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.