Skip to content

Commit

Permalink
Added Changelog for git hashes, removed check modification checks fro…
Browse files Browse the repository at this point in the history
…m ci.yml, restructured git hashes part in lobster-online-report, unit tests added
  • Loading branch information
kedarnn committed Jan 22, 2025
1 parent fa677d9 commit bec9415
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 34 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ jobs:
- name: Coverage analysis
run: |
make coverage
# - name: Check output files
# if: always()
# run: |
# util/check_local_modifications.sh
integration-tests:
name: Integration tests
needs: test
Expand Down Expand Up @@ -127,10 +123,6 @@ jobs:
- name: Run integration tests
run: |
make integration-tests
# - name: Check output files
# if: always()
# run: |
# util/check_local_modifications.sh
failure:
name: Check all jobs
needs: integration-tests
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

### 0.9.22-dev

* `lobster-online-report` - now contains the actual git commit hashes when the user executed the tool.

* The configuration management for the `lobster-cpptest` tool has been migrated from command-line arguments to YAML configuration files.

### 0.9.21
Expand Down
29 changes: 17 additions & 12 deletions lobster/tools/core/online_report/online_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,25 @@ def main():
report = Report()
report.load_report(options.lobster_report)

add_github_references_to_items(gh_root, gh_submodule_roots, gh_submodule_sha, options, repo_root, report)

report.write_report(options.out if options.out else options.lobster_report)
print("LOBSTER report %s changed to use online references" %
options.out if options.out else options.lobster_report)
return 0


def add_github_references_to_items(gh_root, gh_submodule_roots, gh_submodule_sha, options, repo_root, report):
for item in report.items.values():
if isinstance(item.location, File_Reference):
assert os.path.isdir(item.location.filename) or \
os.path.isfile(item.location.filename)
os.path.isfile(item.location.filename)

rel_path_from_root = os.path.relpath(item.location.filename,
repo_root)
# pylint: disable=possibly-used-before-assignment
actual_repo = gh_root
actual_sha = options.commit
actual_sha = options.commit
actual_path = rel_path_from_root
exec_commit_id = subprocess.check_output(
["git", "rev-parse", "HEAD"]
Expand All @@ -234,7 +243,7 @@ def main():
for prefix in gh_submodule_roots:
if path_starts_with_subpath(rel_path_from_root, prefix):
actual_repo = gh_submodule_roots[prefix]
actual_sha = gh_submodule_sha[prefix]
actual_sha = gh_submodule_sha[prefix]
actual_path = rel_path_from_root[len(prefix) + 1:]
exec_commit_id = subprocess.check_output(
["git", "rev-parse", "HEAD"],
Expand All @@ -244,17 +253,13 @@ def main():
break

loc = Github_Reference(
gh_root = actual_repo,
commit = actual_sha,
filename = actual_path,
line = item.location.line,
exec_commit_id = exec_commit_id)
gh_root=actual_repo,
commit=actual_sha,
filename=actual_path,
line=item.location.line,
exec_commit_id=exec_commit_id)
item.location = loc

report.write_report(options.out if options.out else options.lobster_report)
print("LOBSTER report %s changed to use online references" %
options.out if options.out else options.lobster_report)


if __name__ == "__main__":
sys.exit(main())
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
report-lobster.input
report.lobster
--out=expected-output.lobster
13 changes: 1 addition & 12 deletions tests-system/run_tool_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@

# This is the folder containing the folders starting with "rbt-"
REQUIREMENTS_BASED_TEST_PREFIX = "rbt-"

LOBSTER_ONLINE_REPORT_TOOL = "lobster-online-report"
LOBSTER_HTML_REPORT_TOOL = "lobster-html-report"
LOBSTER_CI_REPORT_TOOL = "lobster-ci-report"
tool_name_mapping = {"online_report": LOBSTER_ONLINE_REPORT_TOOL,
"html_report" : LOBSTER_HTML_REPORT_TOOL,
"ci_report" : LOBSTER_CI_REPORT_TOOL}

class TestSetup:
_INPUT_FOLDER_NAME = "input"
Expand Down Expand Up @@ -279,7 +273,7 @@ def _run_tests(directory: Path, tool: str) -> int:
for test_case_dir_entry in _get_directories(rbt_dir_entry.path):
test_setup = TestSetup(test_case_dir_entry.path)
completed_process = _run_test(test_setup, tool)
if basename(tool) in tool_name_mapping.values():
if basename(tool) == LOBSTER_ONLINE_REPORT_TOOL:
for file_name in test_setup.expected_lobster_output_file_names:
expected = join(
test_setup.get_expected_output_path(),
Expand Down Expand Up @@ -309,11 +303,6 @@ def _get_tool(test_dir: str) -> str:
:param test_dir: The path containing the requirements-based tests
"""
return normpath(Path(join("../", basename(test_dir))).absolute())
# return normpath(
# Path(
# join("../", tool_name_mapping.get(basename(test_dir), basename(test_dir)))
# ).absolute()
# )


if __name__ == "__main__":
Expand Down
22 changes: 22 additions & 0 deletions tests-unit/lobster-core/online_report/data/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# --parse-decorator trlc_reference requirement

import potatolib

def trlc_reference(requirement):
# lobster-exclude: helper function
def decorator(obj):
return obj
return decorator

class Example:
@trlc_reference(requirement="example.req_nor")
def helper_function(a, b):
# potato
return a or b

def nor(a, b):
# lobster-trace: example.req_nor
assert isinstance(a, bool)
assert isinstance(b, bool)

return not helper_function(a, b)
38 changes: 37 additions & 1 deletion tests-unit/lobster-core/online_report/test_online_report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
# please consider writing here your tests and set your tracing tags.
# This file will be used in the tracing report
# if any other file or files are used, make the needed
# adjsutments to tracing report target.
# adjsutments to tracing report target.
import argparse
import json
import os
import sys
import unittest
from contextlib import redirect_stdout
from io import StringIO
from os.path import dirname
from pathlib import Path

from lobster.tools.core.online_report.online_report import main


class LobsterOnlineReportTests(unittest.TestCase):
def setUp(self):
self.input_file = str(Path(dirname(__file__), "data", "report.lobster"))
self.online_report = "online-report.lobster"

def test_valid_inputs(self):
sys.argv = ["lobster-online-report", self.input_file, f'--out={self.online_report}']
with StringIO() as stdout, redirect_stdout(stdout):
exit_code = main()
output = stdout.getvalue()
with open(self.online_report, 'r') as file:
data = json.load(file)
for level in data['levels']:
for item in level['items']:
with self.subTest(item):
location = item['location']
if 'file' in location:
self.assertIsNotNone(location.get('exec_commit_id'))
self.assertEqual(exit_code, 0)
self.assertIn(f"LOBSTER report {self.online_report} changed to use online references", output)

def tearDown(self):
os.remove(self.online_report)

0 comments on commit bec9415

Please sign in to comment.