-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better LWJGL version resolver & tests
- Loading branch information
Showing
5 changed files
with
159 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Tests | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "main" branch | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
test: | ||
# The type of runner that the job will run on | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@main | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
- name: Test with tox | ||
run: tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
|
||
import fix_lwjgl | ||
import pytest | ||
|
||
|
||
def test_get_paths() -> None: | ||
assert fix_lwjgl.get_paths( | ||
{ | ||
"": [ | ||
"main.py", | ||
"waffles.txt", | ||
], | ||
"folder": { | ||
"": [ | ||
"folder_one.txt", | ||
], | ||
"inner": { | ||
"": [ | ||
"folder_two.txt", | ||
], | ||
"inner_two": [ | ||
"folder_three.txt", | ||
], | ||
}, | ||
}, | ||
}, | ||
) == [ | ||
"main.py", | ||
"waffles.txt", | ||
os.path.join("folder", "folder_one.txt"), | ||
os.path.join("folder", "inner", "folder_two.txt"), | ||
os.path.join("folder", "inner", "inner_two", "folder_three.txt"), | ||
] | ||
|
||
|
||
def test_get_address() -> None: | ||
assert ( | ||
fix_lwjgl.get_address("CoolCat467", "fix-lwjgl", "HEAD", "README.md") | ||
== "https://raw.githubusercontent.com/CoolCat467/fix-lwjgl/HEAD/README.md" | ||
) | ||
|
||
|
||
def test_get_lwjgl_file_url() -> None: | ||
assert ( | ||
fix_lwjgl.get_lwjgl_file_url("bin/lwjgl/lwjgl.jar") | ||
== "https://build.lwjgl.org/release/latest/bin/lwjgl/lwjgl.jar" | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("version", "expected"), | ||
[ | ||
("17w43b", 3), | ||
("17w42b", 2), | ||
("1.12.2", 2), | ||
("1.13.0", 3), | ||
("1.7.10", 2), | ||
("1.20.1", 3), | ||
], | ||
) | ||
def test_discover_lwjgl_version(version: str, expected: int) -> None: | ||
assert fix_lwjgl.discover_lwjgl_version(version) == expected |