Skip to content

Commit

Permalink
build: prepare to unit test
Browse files Browse the repository at this point in the history
Adopt Technologies:

* PDM - "A modern Python package and dependency manager supporting
the latest PEP standards."
* pyproject.toml - Used by PDM to manage project dependencies and metadata.
* pytest - A nice modern unit testing framework for python.

Reorganized tests, and removed local-min-max test.
They were breaking and are VERY slow. They were intended to mimic
those that run in CI. But those are passing.

Added bin/test/units.bash to run unit tests. Place unit tests in tests/unit/.

No longer supporting python < 3.9.

---

Related to #119
Closes #131

Thanks to
Co-authored-by: Akshar Patel <[email protected]>
He performed the initial research for pyproject.toml
  • Loading branch information
StoneyJackson committed May 1, 2024
1 parent e4b429a commit fe08748
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
name: test_python-3.5.10_Java-11.0.21-tem
name: test_python-3.9.19_Java-11.0.21-tem

on:
pull_request:

jobs:
build:
name: test_python-3.5.10_Java-11.0.21-tem
name: test_python-3.9.19_Java-11.0.21-tem
runs-on: ubuntu-latest
steps:
-
Expand All @@ -22,7 +22,7 @@ jobs:
push: false
build-args: |
JAVA_VERSION=11.0.21-tem
PYTHON_VERSION=3.5.10
PYTHON_VERSION=3.9.19
-
name: Test
uses: addnab/docker-run-action@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# See https://pdm-project.org/latest/usage/project/#working-with-version-control
.pdm-python

# This is created by bin/test/languages.bash. But should not be committed.
languages/

Expand Down
5 changes: 5 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ tasks:
&& sudo ./install.sh /usr/local \
&& cd .. \
&& sudo rm -rf bats-core
echo ""
echo "INSTALLING PDM"
curl -sSL https://pdm-project.org/install-pdm.py | python3 -
echo "export PATH=/workspace/.pyenv_mirror/user/current/bin:\$PATH" >> ~/.bashrc
exec bash
pdm install
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Related repositories:

- [ourPLCC/languages](https://github.com/ourPLCC/languages): Languages implemented in PLCC.
- [ourPLCC/course](https://github.com/ourPLCC/course): Course materials for
teaching a Programming Languages course that uses PLCC.
teaching a Programming Languages course the uses PLCC.

## Options for Installation and Use

Expand All @@ -24,7 +24,7 @@ may help you determine which option is best for you and your class.
| ------ | ------------------- | ----------------------- | ---------- |
| GitPod | Web Browser | * Account on GitPod <br> * Account on hosting service (GitLab/GitHub/Bitbucket) <br> * Knowledge of above and Git | Yes |
| Docker | Docker Desktop | Minimal understanding of Docker | Yes |
| Native | * Bash/Linux-like environment <br> * Java >= 11 <br> * Python >= 3.5 | System administration knowledge | No |
| Native | * Bash/Linux-like environment <br> * Java >= 11 <br> * Python >= 3.9 | System administration knowledge | No |

The advantages of GitPod or Docker are (1) few or no software dependencies
and (2) the ability to provide your class/developers a consistent development
Expand Down Expand Up @@ -141,7 +141,7 @@ and use it to install Java.
### Install Python
Check if you have Python >= 3.5
Check if you have Python >= 3.9
```bash
python3 --version
Expand Down
9 changes: 9 additions & 0 deletions bin/test/units.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euo pipefail

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT_ROOT="$( cd "${SCRIPT_DIR}/../.." &> /dev/null && pwd )"

pdm install
pdm test
96 changes: 96 additions & 0 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[project]
name = "plcc"
version = "8.0.0"
description = "Programming Languages Compiler Compiler"
authors = [
{name = "Tim Fossum", email = "[email protected]"},
{name = "Stoney Jackson", email = "[email protected]"}
]
dependencies = []
requires-python = ">=3.9"
readme = "README.md"
license = {text = "GPL-3.0-or-later"}


[project.scripts]
plcc = "plcc.__main__:main"


[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"


[tool.pdm]
distribution = true


[tool.pdm.dev-dependencies]
dev = [
"pytest>=8.2.0",
]

[tool.pdm.scripts]
test = "pytest"
Empty file added tests/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 0 additions & 25 deletions tests/local-min-max-test/README.md

This file was deleted.

41 changes: 0 additions & 41 deletions tests/local-min-max-test/run.bash

This file was deleted.

Empty file added tests/unit/__init__.py
Empty file.

0 comments on commit fe08748

Please sign in to comment.