forked from fosslight/fosslight_dependency_scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_nuget.py
38 lines (32 loc) · 1.56 KB
/
test_nuget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2021 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0
import os
import pytest
import subprocess
UBUNTU_COMMANDS = [
"fosslight_dependency -p tests/test_nuget -o tests/result/nuget1",
"fosslight_dependency -p tests/test_nuget2 -o tests/result/nuget2"
]
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe")
@pytest.mark.parametrize("input_path, output_path", [
("tests/test_nuget", "tests/result/nuget1"),
("tests/test_nuget2", "tests/result/nuget2")
])
@pytest.mark.ubuntu
def test_ubuntu(input_path, output_path):
command = f"fosslight_dependency -p {input_path} -o {output_path}"
result = subprocess.run(command, shell=True, capture_output=True, text=True)
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}"
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}"
@pytest.mark.parametrize("input_path, output_path", [
(os.path.join("tests", "test_nuget"), os.path.join("tests", "result", "nuget1")),
(os.path.join("tests", "test_nuget2"), os.path.join("tests", "result", "nuget2"))
])
@pytest.mark.windows
def test_windows(input_path, output_path):
command = f"{DIST_PATH} -p {input_path} -o {output_path}"
result = subprocess.run(command, capture_output=True, text=True)
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}"
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}"