Skip to content

Commit 8d2092c

Browse files
committed
refactor run_ubuntu test codes
Signed-off-by: yongjunhong <[email protected]>
1 parent 2f6d816 commit 8d2092c

File tree

12 files changed

+159
-26
lines changed

12 files changed

+159
-26
lines changed

tests/pytest/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pytest
2+
import subprocess
3+
4+
5+
@pytest.fixture
6+
def run_command():
7+
def _run_command(command):
8+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
9+
return result.returncode, result.stdout, result.stderr
10+
return _run_command
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_android -o tests/result/android -m android"
8+
]
9+
10+
11+
def test_android_get_dependency(run_command):
12+
for command in GRADLE_COMMANDS:
13+
return_code, stdout, stderr = run_command(command)
14+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_carthage -o tests/result/carthage -m carthage"
8+
]
9+
10+
11+
def test_carthage_get_dependency(run_command):
12+
for command in GRADLE_COMMANDS:
13+
return_code, stdout, stderr = run_command(command)
14+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_cocoapods -o tests/result/cocoapods -m cocoapods"
8+
]
9+
10+
11+
def test_cocoapods_get_dependency(run_command):
12+
for command in GRADLE_COMMANDS:
13+
return_code, stdout, stderr = run_command(command)
14+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_gradle/jib -o tests/result/gradle",
8+
"fosslight_dependency -p tests/test_gradle2 -o tests/result/gradle2"
9+
]
10+
11+
12+
def test_gradle_get_dependency(run_command):
13+
for command in GRADLE_COMMANDS:
14+
return_code, stdout, stderr = run_command(command)
15+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_helm -o tests/result/helm -m helm"
8+
]
9+
10+
11+
def test_helm_get_dependency(run_command):
12+
for command in GRADLE_COMMANDS:
13+
return_code, stdout, stderr = run_command(command)
14+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_maven1/lombok.maven -o tests/result/maven1",
8+
"fosslight_dependency -p tests/test_maven2 -o tests/result/maven2"
9+
]
10+
11+
12+
def test_maven_get_dependency(run_command):
13+
for command in GRADLE_COMMANDS:
14+
return_code, stdout, stderr = run_command(command)
15+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_npm1 -o tests/result/npm1",
8+
"fosslight_dependency -p tests/test_npm2 -o tests/result/npm2 -m npm"
9+
]
10+
11+
12+
def test_npm_get_dependency(run_command):
13+
for command in GRADLE_COMMANDS:
14+
return_code, stdout, stderr = run_command(command)
15+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_nuget -o tests/result/nuget1",
8+
"fosslight_dependency -p tests/test_nuget2 -o tests/result/nuget2"
9+
]
10+
11+
12+
def test_nuget_get_dependency(run_command):
13+
for command in GRADLE_COMMANDS:
14+
return_code, stdout, stderr = run_command(command)
15+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
GRADLE_COMMANDS = [
7+
"fosslight_dependency -p tests/test_pub -o tests/result/pub",
8+
"fosslight_dependency -p tests/test_exclude -e requirements.txt -o tests/result/exclude"
9+
]
10+
11+
12+
def test_pub_get_dependency(run_command):
13+
for command in GRADLE_COMMANDS:
14+
return_code, stdout, stderr = run_command(command)
15+
assert return_code == 0, f"Command failed: {command}\nstdout: {stdout}\nstderr: {stderr}"

0 commit comments

Comments
 (0)