From 334a900c95d651276a0ef0b4a03e8a16e297e93e Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Mon, 29 Aug 2022 00:10:10 -0500 Subject: [PATCH] Updating standards --- .gitignore | 1 + Makefile | 9 ++++++--- PKGBUILD | 4 ++-- README => README.md | 0 tests/global_fns.py | 33 +++++++++++++++++++++++++++++++++ tests/test_c.py | 24 ++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 5 deletions(-) rename README => README.md (100%) create mode 100644 tests/global_fns.py create mode 100644 tests/test_c.py diff --git a/.gitignore b/.gitignore index ea5dbda..2eac09f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__ *.tar.zst.sig pkg/ src/ +wiki/ diff --git a/Makefile b/Makefile index c0511ba..beae5e3 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ pkgdirname != basename `git config remote.origin.url` | sed 's/.git$$//' -compile: c cs java bash php perl python +compile: c java bash php perl python cs @echo Done -install: clean +install: clean compile test mkdir -p ${pkgdir}/opt/aninix/${pkgdirname}/ - rsync -avzp HelloWorld* ${pkgdir}/opt/aninix/${pkgdirname}/ + install -m root -o 0644 ./HelloWorld* ${pkgdir}/opt/aninix/${pkgdirname}/ test: compile python3 -m pytest @@ -13,6 +13,9 @@ test: compile clean: for i in `cat .gitignore`; do /bin/bash -c "rm -Rf $$i"; done +uninstall: + rm -Rf ${pkgdir}/opt/aninix/${pkgdirname}/ + diff: @echo Nothing to do. diff --git a/PKGBUILD b/PKGBUILD index c632b0e..c96d91c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,7 +5,7 @@ pkgrel() { git log "$(git describe --tag --abbrev=0)"..HEAD | grep -c commit } epoch= -pkgdesc="$(head -n 1 README)" +pkgdesc="$(head -n 1 README.md)" arch=("x86_64") url="https://aninix.net/foundation/${pkgname}" license=('custom') @@ -16,7 +16,7 @@ checkdepends=() optdepends=() provides=("${pkgname}") conflicts=() -replaces=() +replaces=("${pkgname,,}","aninix-${pkgname,,}") backup=() options=() install= diff --git a/README b/README.md similarity index 100% rename from README rename to README.md diff --git a/tests/global_fns.py b/tests/global_fns.py new file mode 100644 index 0000000..ccf844d --- /dev/null +++ b/tests/global_fns.py @@ -0,0 +1,33 @@ +import os +import re +import shutil + +def checkOutput(output): + """ + Ensure hello world is in string. + return: whether hello world is present + """ + return output == 'Hello world!\n' + +def runCommand(command): + """ + Define a function to run a shell commmand and return the output + param command: command to run + return: Whether retcode is 0 + """ + fh = os.popen(command, mode='r', buffering=-1) + output = fh.read() + retcode = fh.close() + assert retcode == None + + +def runCommandAndOutputCheck(command): + """ + Define a function to run a shell command and ensure output is correct + param command: command + return: Whether retcode is 0 && output matches test. + """ + fh = os.popen(command, mode='r', buffering=-1) + output = fh.read() + retcode = fh.close() + assert retcode == None and CheckOutput(output) diff --git a/tests/test_c.py b/tests/test_c.py new file mode 100644 index 0000000..6bde8cb --- /dev/null +++ b/tests/test_c.py @@ -0,0 +1,24 @@ +import os +import re +import shutil + +from tests.global_fns import * + +def test_compile_c(): + fh = os.popen("gcc -o HelloWorld ./HelloWorld.c", mode='r', buffering=-1) + output = fh.read() + retcode = fh.close() + assert retcode == None + + +def test_c(): + fh = os.popen("./HelloWorld", mode='r', buffering=-1) + output = fh.read() + retcode = fh.close() + assert retcode == None and checkOutput(output) + +def test_c_cleanup(): + fh = os.popen("rm ./HelloWorld", mode='r', buffering=-1) + output = fh.read() + retcode = fh.close() + assert retcode == None