Skip to content

Commit

Permalink
Merge pull request #10 from Younis-Ahmed/main
Browse files Browse the repository at this point in the history
Testing Suite was created
  • Loading branch information
Moealsir authored Mar 25, 2024
2 parents 74d5540 + 9fb6d2e commit 273814d
Show file tree
Hide file tree
Showing 19 changed files with 898 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint pycodestyle colorama
pip install pylint pycodestyle colorama pytest pytest-mock
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
pylint $(git ls-files '*.py' | grep -v setup.py)
- name: Analysing the code with pycodestyle
run: |
pycodestyle $(git ls-files '*.py' | grep -v setup.py)
39 changes: 39 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Unit testing application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint pycodestyle colorama pytest pytest-mock
- name: Install ctags
run: sudo apt-get update && sudo apt-get install -y exuberant-ctags
- name: Install betty
run: |
sudo ./bettyfixer/install_dependency/.Betty/install.sh &&
sudo mv bettyfixer/install_dependency/.Betty/betty.sh /bin/betty
- name: Create test-results directory
run: mkdir -p test-results
- name: Test with pytest
run: |
pytest --junitxml=test-results/results.xml
- uses: actions/upload-artifact@v3
if: always()
with:
name: pytest-results
path: test-results
retention-days: 30
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
main.c
__pycache__/
*.pyc
.coverage
htmlcov/
launch.json
2 changes: 1 addition & 1 deletion bettyfixer/autoprototype.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def generate_tags(directory):
return False


def filter_tags(directory, tags_file):
def filter_tags(directory, tags_file): # ❗ This function has bugs
"""
Filter the tags file to get only the function prototypes.
Args:
Expand Down
2 changes: 1 addition & 1 deletion bettyfixer/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_backup(file_path):
shutil.copy2(file_path, backup_path)
except shutil.SameFileError:
print(
f"Err creating backup {file_path}: Src and dest are same file.")
f"Error creating backup {file_path}: Src and dest are same file.")
except FileNotFoundError:
print(f"Error creating backup for {file_path}: File not found.")
except IsADirectoryError:
Expand Down
2 changes: 2 additions & 0 deletions bettyfixer/betty_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def process_errors(file_path):
process_error_file(file_path)


# ❗ Needs to be refactored with Dependency Injection in mind
def fix_betty_warnings(content, file_path):
"""
Fix Betty warnings in the specified content.
Expand Down Expand Up @@ -190,6 +191,7 @@ def remove_blank_lines_inside_comments(file_path):
return


# ❗ in serious need of refactoring. Decoupling and Dependency Injection
def fix_betty_style(file_paths):
"""
Fix Betty style for the specified file paths.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions linter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/env bash

# Get the current date and time
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

# Get the name of the person from git config
NAME=$(git config --get user.name)

# path from the root of project to the directory where the log files will be saved
PATHLOG=$(git rev-parse --show-toplevel)/errors_logs/linting
# Check if pylint is installed
if ! command -v pylint &> /dev/null
then
echo "pylint is not installed"
exit 1
fi

# Check if person's name is set in git config
if [ -z "$(git config --get user.name)" ]
then
echo "Please set your name in git config"
exit 1
fi


if [ ! -d "$PATHLOG" ]
then
mkdir -p "$PATHLOG"
fi
# Loop over all command line arguments
for file in "$@"
do
# Change the file suffix to .txt
filename=$(basename "$file")
output_file="${filename%.py}.txt"

echo -e "\n\nName: $NAME\n" >> "${PATHLOG}/${output_file}"
echo -e "Date: $CURRENT_DATE\n" >> "${PATHLOG}/${output_file}"
pylint "$file"
# Run pylint with the current command line argument
pylint "$file" --reports=y -f parseable >> "${PATHLOG}/${output_file}"
done
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ indent-after-paren=4
indent-string=' '

# Maximum number of characters on a single line.
max-line-length=100
max-line-length=79

# Maximum number of lines in a module.
max-module-lines=1000
Expand Down
Empty file added tests/__init__.py
Empty file.
Loading

0 comments on commit 273814d

Please sign in to comment.