From 33fc26049100b3abbe3568d126abe31e9c0b1881 Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Thu, 17 Aug 2023 03:11:44 +0530 Subject: [PATCH 1/8] Add last_passed_on in regression_test table Signed-off-by: Tarun Arora --- migrations/versions/b3ed927671bd_.py | 31 +++++++++++++++++++++++++ mod_ci/controllers.py | 15 ++++++++++-- mod_regression/models.py | 2 ++ templates/ci/pr_comment.txt | 34 +--------------------------- 4 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 migrations/versions/b3ed927671bd_.py diff --git a/migrations/versions/b3ed927671bd_.py b/migrations/versions/b3ed927671bd_.py new file mode 100644 index 00000000..74e42105 --- /dev/null +++ b/migrations/versions/b3ed927671bd_.py @@ -0,0 +1,31 @@ +"""empty message + +Revision ID: b3ed927671bd +Revises: a5183973c3e9 +Create Date: 2023-08-17 00:41:01.237549 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = 'b3ed927671bd' +down_revision = 'a5183973c3e9' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('regression_test', schema=None) as batch_op: + batch_op.add_column(sa.Column('last_passed_on', sa.Integer(), nullable=True)) + batch_op.create_foreign_key(None, 'test', ['last_passed_on'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('regression_test', schema=None) as batch_op: + batch_op.drop_column('last_passed_on') + # ### end Alembic commands ### diff --git a/mod_ci/controllers.py b/mod_ci/controllers.py index f0dea1e6..e08eb3bd 100755 --- a/mod_ci/controllers.py +++ b/mod_ci/controllers.py @@ -1135,6 +1135,10 @@ def update_build_badge(status, test) -> None: shutil.copyfile(original_location, build_status_location) g.log.info('Build badge updated successfully!') + regression_testid_passed = get_subquery_regression_testid_passed(test.id) + test_ids_to_update = [result[0] for result in regression_testid_passed] + g.db.query(RegressionTest).filter(RegressionTest.id.in_(test_ids_to_update)).update({"last_passed_on": test.id}, synchronize_session=False) + g.db.commit() @mod_ci.route('/progress-reporter//', methods=['POST']) def progress_reporter(test_id, token): @@ -1546,8 +1550,7 @@ def set_avg_time(platform, process_type: str, time_taken: int) -> None: g.db.commit() -def get_info_for_pr_comment(test_id: int) -> PrCommentInfo: - """Return info about the given test id for use in a PR comment.""" +def get_subquery_regression_testid_passed(test_id: int): regression_testid_passed = g.db.query(TestResult.regression_test_id).outerjoin( TestResultFile, TestResult.test_id == TestResultFile.test_id).filter( TestResult.test_id == test_id, @@ -1571,6 +1574,14 @@ def get_info_for_pr_comment(test_id: int) -> PrCommentInfo: TestResultFile.got == RegressionTestOutputFiles.file_hashes ))) )).distinct().union(g.db.query(regression_testid_passed.c.regression_test_id)) + + return regression_testid_passed + + +def get_info_for_pr_comment(test_id: int) -> PrCommentInfo: + """Return info about the given test id for use in a PR comment.""" + + regression_testid_passed = get_subquery_regression_testid_passed(test_id) passed = g.db.query(label('category_id', Category.id), label( 'success', count(regressionTestLinkTable.c.regression_id))).filter( diff --git a/mod_regression/models.py b/mod_regression/models.py index 3a8abb44..6abc86e9 100644 --- a/mod_regression/models.py +++ b/mod_regression/models.py @@ -95,6 +95,8 @@ class RegressionTest(Base): expected_rc = Column(Integer) active = Column(Boolean(), default=True) + last_passed_on = Column(Integer, ForeignKey('test.id', onupdate="CASCADE", ondelete="SET NULL")) + def __init__(self, sample_id, command, input_type, output_type, category_id, expected_rc, active=True) -> None: """ Parametrized constructor for the RegressionTest model. diff --git a/templates/ci/pr_comment.txt b/templates/ci/pr_comment.txt index 6af243d6..d8121eb2 100644 --- a/templates/ci/pr_comment.txt +++ b/templates/ci/pr_comment.txt @@ -1,33 +1 @@ -CCExtractor CI platform finished running the test files on {{platform}}. Below is a summary of the test results: - - - - - -{% for test in tests%} - - -{% if test.success==None %} - -{% elif test.success == test.total %} - -{% else %} - -{% endif %} - -{% endfor %} -
Report Name Tests Passed
{{test.category}} 0/{{test.total}} {{test.success}}/{{test.total}} {{test.success}}/{{test.total}}
-{% if state == "failure" %} -It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). - -Your PR breaks these cases: - -{% else %} -All tests were passed completely. -{% endif %} -
-Check the result page for more info. +'CCExtractor CI platform finished running the test files on None.\nBelow is a summary of the test results:\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Report Name Tests Passed
Broken 13/13
CEA-708 2/14
DVB 4/7
DVD 3/3
DVR-MS 2/2
General 24/27
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 85/87
Teletext 21/21
WTV 13/13
XDS 31/34
\n\nIt seems that not all tests were passed completely. This is an indication that the output of some files is not as\nexpected (but might be according to you).\n\nYour PR breaks these cases:\n
    \n \n
  • \n ccextractor -autoprogram -out=srt -latin1\n 85271be4d2...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1\n 1974a299f0...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1\n 132d7df7e9...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1\n 99e5eaafdc...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -xds -latin1 -ucla\n e274a73653...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1 -ucla -xds\n b22260d065...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1 -ucla -xds\n 88cd42b89a...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt -nobom -noru\n ea83ff7bcb...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt\n f17524b53f...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt\n 80848c45f8...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt -nobom -noru\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc 1[EUC-KR] -out=txt -noru\n b5d6aad89f...\n \n , Last Passed: Test\n 4461\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=srt\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=sami\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc 1[EUC-KR]\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc 1[EUC-KR] -noru\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc all\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc all[EUC-KR]\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc 1,2[UTF-8],3[EUC-KR],54 -out=txt\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc 1\n c83f765c66...\n \n
  • \n \n
  • \n ccextractor --capfile /repository/Dictionary/MattS_dictionary.txt\n c83f765c66...\n \n
  • \n \n
  • \n ccextractor -stdout -quiet -nofc\n 79a51f3500...\n \n
  • \n \n
  • \n ccextractor -stdout -quiet -nofc\n 767b546f96...\n \n
  • \n \n
\n\n
\nCheck the result page for more info.' \ No newline at end of file From 99bbb4490e3a18fbfc2eb5d3467a2e815501c9d2 Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Sun, 20 Aug 2023 11:49:51 +0530 Subject: [PATCH 2/8] Fix formatting and pydocstyle issues Signed-off-by: Tarun Arora --- migrations/versions/b3ed927671bd_.py | 2 +- mod_ci/controllers.py | 22 ++++++++++---- mod_regression/models.py | 1 - templates/ci/pr_comment.txt | 43 +++++++++++++++++++++++++++- 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/migrations/versions/b3ed927671bd_.py b/migrations/versions/b3ed927671bd_.py index 74e42105..ef588708 100644 --- a/migrations/versions/b3ed927671bd_.py +++ b/migrations/versions/b3ed927671bd_.py @@ -5,8 +5,8 @@ Create Date: 2023-08-17 00:41:01.237549 """ -from alembic import op import sqlalchemy as sa +from alembic import op from sqlalchemy.dialects import mysql # revision identifiers, used by Alembic. diff --git a/mod_ci/controllers.py b/mod_ci/controllers.py index e08eb3bd..7fb64ec7 100755 --- a/mod_ci/controllers.py +++ b/mod_ci/controllers.py @@ -23,6 +23,7 @@ from markdown2 import markdown from pymysql.err import IntegrityError from sqlalchemy import and_, func, or_ +from sqlalchemy.orm.query import Query from sqlalchemy.sql import label from sqlalchemy.sql.functions import count from werkzeug.utils import secure_filename @@ -1135,11 +1136,13 @@ def update_build_badge(status, test) -> None: shutil.copyfile(original_location, build_status_location) g.log.info('Build badge updated successfully!') - regression_testid_passed = get_subquery_regression_testid_passed(test.id) + regression_testid_passed = get_query_regression_testid_passed(test.id) test_ids_to_update = [result[0] for result in regression_testid_passed] - g.db.query(RegressionTest).filter(RegressionTest.id.in_(test_ids_to_update)).update({"last_passed_on": test.id}, synchronize_session=False) + g.db.query(RegressionTest).filter(RegressionTest.id.in_(test_ids_to_update) + ).update({"last_passed_on": test.id}, synchronize_session=False) g.db.commit() + @mod_ci.route('/progress-reporter//', methods=['POST']) def progress_reporter(test_id, token): """ @@ -1550,7 +1553,14 @@ def set_avg_time(platform, process_type: str, time_taken: int) -> None: g.db.commit() -def get_subquery_regression_testid_passed(test_id: int): +def get_query_regression_testid_passed(test_id: int) -> Query: + """Get sqlalchemy query to fetch all regression tests which passed on given test id. + + :param test_id: test id of the test whose query is required + :type test_id: int + :return: Query object for passed regression tests + :rtype: sqlalchemy.orm.query.Query + """ regression_testid_passed = g.db.query(TestResult.regression_test_id).outerjoin( TestResultFile, TestResult.test_id == TestResultFile.test_id).filter( TestResult.test_id == test_id, @@ -1574,14 +1584,14 @@ def get_subquery_regression_testid_passed(test_id: int): TestResultFile.got == RegressionTestOutputFiles.file_hashes ))) )).distinct().union(g.db.query(regression_testid_passed.c.regression_test_id)) - + return regression_testid_passed def get_info_for_pr_comment(test_id: int) -> PrCommentInfo: """Return info about the given test id for use in a PR comment.""" - - regression_testid_passed = get_subquery_regression_testid_passed(test_id) + + regression_testid_passed = get_query_regression_testid_passed(test_id) passed = g.db.query(label('category_id', Category.id), label( 'success', count(regressionTestLinkTable.c.regression_id))).filter( diff --git a/mod_regression/models.py b/mod_regression/models.py index 6abc86e9..ae5e6a28 100644 --- a/mod_regression/models.py +++ b/mod_regression/models.py @@ -94,7 +94,6 @@ class RegressionTest(Base): output_files = relationship('RegressionTestOutput', back_populates='regression_test') expected_rc = Column(Integer) active = Column(Boolean(), default=True) - last_passed_on = Column(Integer, ForeignKey('test.id', onupdate="CASCADE", ondelete="SET NULL")) def __init__(self, sample_id, command, input_type, output_type, category_id, expected_rc, active=True) -> None: diff --git a/templates/ci/pr_comment.txt b/templates/ci/pr_comment.txt index d8121eb2..9d5bc4e9 100644 --- a/templates/ci/pr_comment.txt +++ b/templates/ci/pr_comment.txt @@ -1 +1,42 @@ -'CCExtractor CI platform finished running the test files on None.\nBelow is a summary of the test results:\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Report Name Tests Passed
Broken 13/13
CEA-708 2/14
DVB 4/7
DVD 3/3
DVR-MS 2/2
General 24/27
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 85/87
Teletext 21/21
WTV 13/13
XDS 31/34
\n\nIt seems that not all tests were passed completely. This is an indication that the output of some files is not as\nexpected (but might be according to you).\n\nYour PR breaks these cases:\n
    \n \n
  • \n ccextractor -autoprogram -out=srt -latin1\n 85271be4d2...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1\n 1974a299f0...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1\n 132d7df7e9...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1\n 99e5eaafdc...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -xds -latin1 -ucla\n e274a73653...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1 -ucla -xds\n b22260d065...\n \n
  • \n \n
  • \n ccextractor -autoprogram -out=ttxt -latin1 -ucla -xds\n 88cd42b89a...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt -nobom -noru\n ea83ff7bcb...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt\n f17524b53f...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt\n 80848c45f8...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=txt -nobom -noru\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc 1[EUC-KR] -out=txt -noru\n b5d6aad89f...\n \n , Last Passed: Test\n 4461\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=srt\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc 1 -out=sami\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc 1[EUC-KR]\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc 1[EUC-KR] -noru\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc all\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc all[EUC-KR]\n b5d6aad89f...\n \n
  • \n \n
  • \n ccextractor -svc 1,2[UTF-8],3[EUC-KR],54 -out=txt\n da904de35d...\n \n
  • \n \n
  • \n ccextractor -svc 1\n c83f765c66...\n \n
  • \n \n
  • \n ccextractor --capfile /repository/Dictionary/MattS_dictionary.txt\n c83f765c66...\n \n
  • \n \n
  • \n ccextractor -stdout -quiet -nofc\n 79a51f3500...\n \n
  • \n \n
  • \n ccextractor -stdout -quiet -nofc\n 767b546f96...\n \n
  • \n \n
\n\n
\nCheck the result page for more info.' \ No newline at end of file +CCExtractor CI platform finished running the test files on {{platform}}. Below is a summary of the test +results: + + + + + + {% for test in tests%} + + + {% if test.success==None %} + + {% elif test.success == test.total %} + + {% else %} + + {% endif %} + + {% endfor %} +
Report Name Tests Passed
{{test.category}} 0/{{test.total}} {{test.success}}/{{test.total}} {{test.success}}/{{test.total}}
+{% if state == "failure" %} +It seems that not all tests were passed completely. This is an indication that the output of some files is not as +expected (but might be according to you). + +Your PR breaks these cases: +
    + {% for test in failed_tests %} +
  • ccextractor {{ test.command }} + + {{ test.sample.sha[:10] }}... + + {% if test.last_passed_on %} + , Last passed: + {% endif %} +
  • + {% endfor %} +
+{% else %} +All tests were passed completely. +{% endif %} +
+Check the result page for more info. From c83d3c7e68d5115a1e9b0eb3be5dcc6bb1b10b85 Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Sun, 20 Aug 2023 11:54:23 +0530 Subject: [PATCH 3/8] Remove blank line after docstring Signed-off-by: Tarun Arora --- mod_ci/controllers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mod_ci/controllers.py b/mod_ci/controllers.py index 7fb64ec7..4eae849a 100755 --- a/mod_ci/controllers.py +++ b/mod_ci/controllers.py @@ -1590,7 +1590,6 @@ def get_query_regression_testid_passed(test_id: int) -> Query: def get_info_for_pr_comment(test_id: int) -> PrCommentInfo: """Return info about the given test id for use in a PR comment.""" - regression_testid_passed = get_query_regression_testid_passed(test_id) passed = g.db.query(label('category_id', Category.id), label( From 3b9462073c39897fb6a990471ee4494e193a0db0 Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Sun, 20 Aug 2023 12:29:39 +0530 Subject: [PATCH 4/8] Add description field for regression tests Signed-off-by: Tarun Arora --- migrations/versions/b3ed927671bd_.py | 7 +++++-- mod_regression/controllers.py | 5 ++++- mod_regression/forms.py | 3 ++- mod_regression/models.py | 4 +++- templates/regression/test_add.html | 3 +++ templates/regression/test_edit.html | 3 +++ templates/regression/test_view.html | 1 + 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/migrations/versions/b3ed927671bd_.py b/migrations/versions/b3ed927671bd_.py index ef588708..936dd933 100644 --- a/migrations/versions/b3ed927671bd_.py +++ b/migrations/versions/b3ed927671bd_.py @@ -1,4 +1,4 @@ -"""empty message +"""Add last_passed_on and description fields in regression_test Revision ID: b3ed927671bd Revises: a5183973c3e9 @@ -20,12 +20,15 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('regression_test', schema=None) as batch_op: batch_op.add_column(sa.Column('last_passed_on', sa.Integer(), nullable=True)) - batch_op.create_foreign_key(None, 'test', ['last_passed_on'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + batch_op.create_foreign_key('regression_test_ibfk_2', 'test', ['last_passed_on'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + batch_op.add_column(sa.Column('description', sa.String(length=1024), nullable=True)) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('regression_test', schema=None) as batch_op: + batch_op.drop_constraint('regression_test_ibfk_2', type_='foreignkey') batch_op.drop_column('last_passed_on') + batch_op.drop_column('description') # ### end Alembic commands ### diff --git a/mod_regression/controllers.py b/mod_regression/controllers.py index 871e3ee0..c50c7649 100644 --- a/mod_regression/controllers.py +++ b/mod_regression/controllers.py @@ -159,6 +159,7 @@ def test_edit(regression_id): test.expected_rc = form.expected_rc.data test.input_type = InputType.from_string(form.input_type.data) test.output_type = OutputType.from_string(form.output_type.data) + test.description = form.description.data g.db.commit() g.log.info(f'regression test with id: {regression_id} updated!') @@ -172,6 +173,7 @@ def test_edit(regression_id): form.expected_rc.data = test.expected_rc form.input_type.data = test.input_type.value form.output_type.data = test.output_type.value + form.description.data = test.description return {'form': form, 'regression_id': regression_id} @@ -241,7 +243,8 @@ def test_add(): category_id=form.category_id.data, expected_rc=form.expected_rc.data, input_type=InputType.from_string(form.input_type.data), - output_type=OutputType.from_string(form.output_type.data) + output_type=OutputType.from_string(form.output_type.data), + description=form.description.data, ) g.db.add(new_test) category = Category.query.filter(Category.id == form.category_id.data).first() diff --git a/mod_regression/forms.py b/mod_regression/forms.py index fe8a4c22..27686e1d 100644 --- a/mod_regression/forms.py +++ b/mod_regression/forms.py @@ -2,7 +2,7 @@ from flask_wtf import FlaskForm from wtforms import (HiddenField, IntegerField, SelectField, StringField, - SubmitField) + SubmitField, TextAreaField) from wtforms.validators import DataRequired, InputRequired from mod_regression.models import InputType, OutputType @@ -21,6 +21,7 @@ class CommonTestForm(FlaskForm): sample_id = SelectField("Sample", coerce=int) command = StringField("Command") + description = TextAreaField("Description") input_type = SelectField( "Input Type", [DataRequired(message="Input Type is not selected")], diff --git a/mod_regression/models.py b/mod_regression/models.py index ae5e6a28..0b76575a 100644 --- a/mod_regression/models.py +++ b/mod_regression/models.py @@ -95,8 +95,9 @@ class RegressionTest(Base): expected_rc = Column(Integer) active = Column(Boolean(), default=True) last_passed_on = Column(Integer, ForeignKey('test.id', onupdate="CASCADE", ondelete="SET NULL")) + description = Column(String(length=1024)) - def __init__(self, sample_id, command, input_type, output_type, category_id, expected_rc, active=True) -> None: + def __init__(self, sample_id, command, input_type, output_type, category_id, expected_rc, active=True, description="") -> None: """ Parametrized constructor for the RegressionTest model. @@ -123,6 +124,7 @@ def __init__(self, sample_id, command, input_type, output_type, category_id, exp self.category_id = category_id self.expected_rc = expected_rc self.active = active + self.description = description def __repr__(self) -> str: """ diff --git a/templates/regression/test_add.html b/templates/regression/test_add.html index a6a95204..78980605 100644 --- a/templates/regression/test_add.html +++ b/templates/regression/test_add.html @@ -38,6 +38,9 @@
Regression Test Add
{{ macros.render_field(form.sample_id) }}
+
+ {{ macros.render_field(form.description) }} +
{{ macros.render_field(form.command) }}
diff --git a/templates/regression/test_edit.html b/templates/regression/test_edit.html index 91cf2f99..81b9bece 100644 --- a/templates/regression/test_edit.html +++ b/templates/regression/test_edit.html @@ -39,6 +39,9 @@

Regression Test Edit

{{ macros.render_field(form.command) }}
+
+ {{ macros.render_field(form.description) }} +
{{ macros.render_field(form.input_type) }}
diff --git a/templates/regression/test_view.html b/templates/regression/test_view.html index a7c8d38e..7dda99a4 100644 --- a/templates/regression/test_view.html +++ b/templates/regression/test_view.html @@ -11,6 +11,7 @@

Regression test {{ test.id }}

Command: {{ test.command }}

Input type: {{ test.input_type.description }}

Output type: {{ test.output_type.description }}

+

Description: {{ test.description or "No description" }}

Output files:

    {% for i in range(test.output_files|length) %} From 33da43add606b74af5b5ad05bb0f631e0fc097bb Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Sun, 20 Aug 2023 12:32:42 +0530 Subject: [PATCH 5/8] Fix pycodestyle issues Signed-off-by: Tarun Arora --- mod_regression/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod_regression/models.py b/mod_regression/models.py index 0b76575a..a790b53f 100644 --- a/mod_regression/models.py +++ b/mod_regression/models.py @@ -97,7 +97,8 @@ class RegressionTest(Base): last_passed_on = Column(Integer, ForeignKey('test.id', onupdate="CASCADE", ondelete="SET NULL")) description = Column(String(length=1024)) - def __init__(self, sample_id, command, input_type, output_type, category_id, expected_rc, active=True, description="") -> None: + def __init__(self, sample_id, command, input_type, output_type, category_id, expected_rc, + active=True, description="") -> None: """ Parametrized constructor for the RegressionTest model. From 1a0324872e40887afdd17a57889cacb21d9f4b4b Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Sun, 20 Aug 2023 13:12:19 +0530 Subject: [PATCH 6/8] Add test label in last passed on for PR comment Signed-off-by: Tarun Arora --- templates/ci/pr_comment.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ci/pr_comment.txt b/templates/ci/pr_comment.txt index 9d5bc4e9..c3d0565e 100644 --- a/templates/ci/pr_comment.txt +++ b/templates/ci/pr_comment.txt @@ -30,7 +30,7 @@ Your PR breaks these cases: {{ test.sample.sha[:10] }}... {% if test.last_passed_on %} - , Last passed: + , Last passed: Test {{ test.last_passed_on }} {% endif %} {% endfor %} From 5829ba31aaeba6ae689764bc77ae9a943b842bfc Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Sat, 26 Aug 2023 21:54:37 +0530 Subject: [PATCH 7/8] Add unittests and add check on description length Signed-off-by: Tarun Arora --- mod_regression/forms.py | 4 ++-- templates/ci/pr_comment.txt | 6 ++++-- tests/test_regression/test_controllers.py | 10 ++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mod_regression/forms.py b/mod_regression/forms.py index 27686e1d..c01b377b 100644 --- a/mod_regression/forms.py +++ b/mod_regression/forms.py @@ -3,7 +3,7 @@ from flask_wtf import FlaskForm from wtforms import (HiddenField, IntegerField, SelectField, StringField, SubmitField, TextAreaField) -from wtforms.validators import DataRequired, InputRequired +from wtforms.validators import DataRequired, InputRequired, Length from mod_regression.models import InputType, OutputType @@ -21,7 +21,7 @@ class CommonTestForm(FlaskForm): sample_id = SelectField("Sample", coerce=int) command = StringField("Command") - description = TextAreaField("Description") + description = TextAreaField("Description", validators=[Length(max=1024)]) input_type = SelectField( "Input Type", [DataRequired(message="Input Type is not selected")], diff --git a/templates/ci/pr_comment.txt b/templates/ci/pr_comment.txt index c3d0565e..2714e871 100644 --- a/templates/ci/pr_comment.txt +++ b/templates/ci/pr_comment.txt @@ -27,10 +27,12 @@ Your PR breaks these cases: {% for test in failed_tests %}
  • ccextractor {{ test.command }} - {{ test.sample.sha[:10] }}... + {{ test.sample.sha[:10] }}..., Last passed: {% if test.last_passed_on %} - , Last passed: Test {{ test.last_passed_on }} + Test {{ test.last_passed_on }} + {% else %} + Never {% endif %}
  • {% endfor %} diff --git a/tests/test_regression/test_controllers.py b/tests/test_regression/test_controllers.py index 70ac9d6d..74d4b1eb 100644 --- a/tests/test_regression/test_controllers.py +++ b/tests/test_regression/test_controllers.py @@ -256,6 +256,16 @@ def test_category_delete(self): )) self.assertEqual(response.status_code, 302) + def test_edit_test_get_request(self): + """Test editing of regression test with a GET request.""" + self.create_user_with_role(self.user.name, self.user.email, self.user.password, Role.admin) + + with self.app.test_client() as c: + c.post('/account/login', data=self.create_login_form_data(self.user.email, self.user.password)) + response = c.get('/regression/test/2/edit') + self.assertEqual(response.status_code, 200) + self.assertIn('Editing regression test with id 2', str(response.data)) + def test_edit_test(self): """Check it will edit a regression test.""" self.create_user_with_role(self.user.name, self.user.email, self.user.password, Role.admin) From 423a0950d6699205aae4ec576d59a3973a733299 Mon Sep 17 00:00:00 2001 From: Tarun Arora Date: Sat, 26 Aug 2023 23:37:05 +0530 Subject: [PATCH 8/8] Fix formatting issues in pr_comment.txt Signed-off-by: Tarun Arora --- templates/ci/pr_comment.txt | 53 +++++++++++++++---------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/templates/ci/pr_comment.txt b/templates/ci/pr_comment.txt index 2714e871..2ecc8271 100644 --- a/templates/ci/pr_comment.txt +++ b/templates/ci/pr_comment.txt @@ -1,41 +1,30 @@ -CCExtractor CI platform finished running the test files on {{platform}}. Below is a summary of the test -results: +CCExtractor CI platform finished running the test files on {{platform}}. Below is a summary of the test results: - - - - - {% for test in tests%} - - - {% if test.success==None %} - - {% elif test.success == test.total %} - - {% else %} - - {% endif %} - - {% endfor %} + + + + +{% for test in tests%} + + +{% if test.success==None %} + +{% elif test.success == test.total %} + +{% else %} + +{% endif %} + +{% endfor %}
    Report Name Tests Passed
    {{test.category}} 0/{{test.total}} {{test.success}}/{{test.total}} {{test.success}}/{{test.total}}
    Report Name Tests Passed
    {{test.category}} 0/{{test.total}} {{test.success}}/{{test.total}} {{test.success}}/{{test.total}}
    {% if state == "failure" %} -It seems that not all tests were passed completely. This is an indication that the output of some files is not as -expected (but might be according to you). +It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Your PR breaks these cases: {% else %} All tests were passed completely.