Skip to content

Commit 15043a6

Browse files
authored
Modify to test add mode
2 parents d154af1 + 96cd76c commit 15043a6

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/fosslight_reuse/_add.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def set_missing_license_copyright(missing_license_filtered, missing_copyright_fi
130130
run(parsed_args, project)
131131
except Exception as ex:
132132
print_error('Error_call_run_in_license :' + str(ex))
133+
else:
134+
logger.info("# There is no missing license file")
133135

134136
# Print copyright
135137
if missing_copyright_filtered is not None and len(missing_copyright_filtered) > 0:
@@ -142,14 +144,14 @@ def set_missing_license_copyright(missing_license_filtered, missing_copyright_fi
142144

143145
if license == "" and copyright == "":
144146
input_copyright = input_copyright_while_running()
145-
146-
input_ok = check_input_format(input_copyright)
147-
if input_ok is False:
148-
return
149147
else:
150148
input_copyright = copyright
151149

152150
if input_copyright != "":
151+
input_copyright = 'Copyright ' + input_copyright
152+
input_ok = check_input_format(input_copyright)
153+
if input_ok is False:
154+
return
153155
logger.warning(f" * Your input Copyright : {input_copyright}")
154156
parsed_args = main_parser.parse_args(['addheader', '--copyright',
155157
'SPDX-FileCopyrightText: ' + str(input_copyright),
@@ -158,6 +160,8 @@ def set_missing_license_copyright(missing_license_filtered, missing_copyright_fi
158160
run(parsed_args, project)
159161
except Exception as ex:
160162
print_error('Error_call_run_in_copyright :' + str(ex))
163+
else:
164+
logger.info("# There is no missing copyright file\n")
161165

162166

163167
def get_allfiles_list(path):
@@ -197,11 +201,6 @@ def add_content(path_to_find, file, input_license="", input_copyright=""):
197201
logger, _result_log = init_log(os.path.join(output_dir, "fosslight_reuse_add_log_"+now+".txt"),
198202
True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_find)
199203

200-
if input_copyright != "":
201-
input_ok = check_input_format(input_copyright)
202-
if input_ok is False:
203-
return
204-
205204
if file != "":
206205
file_to_check_list = file.split(',')
207206
_check_only_file_mode = True
@@ -221,12 +220,15 @@ def add_content(path_to_find, file, input_license="", input_copyright=""):
221220
run(parsed_args, project)
222221
except Exception as ex:
223222
print_error('Error_call_run_in_license_file_only :' + str(ex))
223+
else:
224+
logger.info("# There is no missing license file")
224225

225226
if missing_copyright_list is not None and len(missing_copyright_list) > 0:
226227
if input_license == "" and input_copyright == "":
227228
input_copyright = input_copyright_while_running()
228229

229230
if input_copyright != "":
231+
input_copyright = 'Copyright ' + input_copyright
230232
logger.warning(f" * Your input Copyright : {input_copyright}")
231233
parsed_args = main_parser.parse_args(['addheader', '--copyright',
232234
'SPDX-FileCopyrightText: ' + str(input_copyright),
@@ -235,6 +237,8 @@ def add_content(path_to_find, file, input_license="", input_copyright=""):
235237
run(parsed_args, project)
236238
except Exception as ex:
237239
print_error('Error_call_run_in_copyright_file_only :' + str(ex))
240+
else:
241+
logger.info("# There is no missing copyright file\n")
238242
else:
239243
# Get all files List in path
240244
all_files_list = get_allfiles_list(path_to_find)

tox.ini

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ basepython= python3.6
1010
whitelist_externals = cat
1111
cp
1212
rm
13+
git
1314
setenv =
1415
PYTHONPATH=.
1516

@@ -23,23 +24,25 @@ filterwarnings = ignore::DeprecationWarning
2324
[testenv:test_run]
2425
commands =
2526
fosslight_reuse lint -p src/ -o "test_result/reuse_result.xml"
26-
fosslight_reuse lint -p src/ -f "fosslight_reuse/wrapper_reuse_lint.py" -o "test_result2/reuse_result.xml"
27+
fosslight_reuse lint -p src/ -f "fosslight_reuse/_fosslight_reuse.py" -o "test_result2/reuse_result.xml"
2728
fosslight_reuse report -p tests/report
2829
fosslight_reuse report -f tests/report/OSS-Report-Sample_1_BOM.xlsx -o test_report/output
2930
cat test_report/output.yaml
3031
rm -rf tests/add_result
3132
cp -r tests/add tests/add_result
32-
fosslight_reuse add -p tests/add_result -c "Copyright 2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
33+
fosslight_reuse add -p tests/add_result -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
34+
rm -rf reuse_example
35+
git clone https://github.com/LGE-OSS/example.git reuse_example
3336
[testenv:release]
3437
deps =
3538
-r{toxinidir}/requirements-dev.txt
3639

3740
commands =
3841
fosslight_reuse -h
3942
fosslight_reuse lint -p src/ -o "test_result/reuse_result.xml"
40-
fosslight_reuse lint -p src/ -f "fosslight_reuse/wrapper_reuse_lint.py" -o "test_result2/reuse_result.xml"
43+
fosslight_reuse lint -p src/ -f "fosslight_reuse/_fosslight_reuse.py" -o "test_result2/reuse_result.xml"
4144
fosslight_reuse report -p tests/report
4245
fosslight_reuse report -f tests/report/OSS-Report-Sample_1_BOM.xlsx -o test_report/output
4346
cp -r tests/add tests/add_result
44-
fosslight_reuse add -p tests/add_result -c "Copyright 2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
47+
fosslight_reuse add -p tests/add_result -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
4548
pytest -v --flake8

0 commit comments

Comments
 (0)