Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
d0467d2
FEAT: impl new tests container
Paliak Dec 20, 2023
bc1de3f
FEAT: initial implementaion of test build logic
Paliak Dec 25, 2023
ad84c6a
DOCS: add some documentation on how to use emmy lua with docker
Paliak Dec 25, 2023
97529ce
DOCS: update line about modcache
Paliak Dec 25, 2023
7b3d334
FIX: docker compose build-diff script
Paliak Dec 25, 2023
b0a455a
FIX: simplify test.yml
Paliak Dec 25, 2023
2c334d2
FIX: make sure directory is root before takign hash of dev
Paliak Dec 25, 2023
60dca6e
FIX: use dedicated cache folder in spec
Paliak Dec 25, 2023
a75b2a1
FIX: use non conical sparse checkout due to a non directory path
Paliak Dec 25, 2023
0875d6e
FIX: path issue when generating dev builds
Paliak Dec 25, 2023
9d581fc
FIX: remove outdate cache when using docker compose
Paliak Dec 25, 2023
3ea5a77
TEST: test tests
Paliak Dec 25, 2023
8883655
Revert "TEST: test tests"
Paliak Dec 25, 2023
3304edd
FIX: issues with docker-compose
Paliak Dec 25, 2023
9f7e0e8
FIX: typo in docker-compose
Paliak Dec 26, 2023
f48955b
FIX: pull out path generation into a variable
Paliak Dec 26, 2023
0bccf5d
FIX: make the build cache back into valid lua file
Paliak Dec 28, 2023
bfc3887
FIX: github actions uses sh -e which uses the diff exit code.
Paliak Dec 29, 2023
412dc18
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Dec 31, 2023
1151597
FIX: manually trigger gc to stave off out of memory crash. Misc fixes.
Paliak Jan 1, 2024
4640e81
FIX: remove outdated comment
Paliak Jan 1, 2024
e49be40
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 4, 2024
d472b1e
FEAT: add needed pkgs to Dockerfile
Paliak Jan 5, 2024
203f9b8
FIX: minor hardening of test runner containers
Paliak Jan 5, 2024
1ff1d08
FEAT: more verbose diff. Fixes to timeless data. Impl import from link.
Paliak Jan 5, 2024
933ee46
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 5, 2024
b11a199
Merge branch 'dev' of https://github.com/Paliak/PathOfBuilding into dev
Paliak Jan 5, 2024
c60cd20
FIX: update the test.yml action
Paliak Jan 5, 2024
51f09ac
FIX: more info for mismatch count
Paliak Jan 5, 2024
9328c99
FEAT: add more builds
Paliak Jan 5, 2024
ecc4d61
FIX: luadiff script
Paliak Jan 5, 2024
5434b3c
FIX: specify origin for dev ref
Paliak Jan 5, 2024
6b86ef6
FIX: fetch a commit from every branch
Paliak Jan 5, 2024
e6f44c5
FIX: unknown ref git error
Paliak Jan 5, 2024
b2a9f55
FIX: minor security/convenience improvements
Paliak Jan 6, 2024
529336a
FEAT: cache downloaded builds
Paliak Jan 6, 2024
6e0829f
FIX: cache folder permissions on github action
Paliak Jan 6, 2024
18623c5
FIX: temp batch files getting clobbered
Paliak Jan 6, 2024
4190be8
FIX: cache folder permissions again
Paliak Jan 6, 2024
61b3d10
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 9, 2024
cdb3143
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 15, 2024
ea6d72f
FIX: apply suggestions. Docs wording. Use repo owner in docker label.
Paliak Jan 15, 2024
5380e0c
FIX: line ending issue on windows
Paliak Jan 18, 2024
a26750d
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 21, 2024
516df64
FIX: rename magiclines func.
Paliak Jan 21, 2024
ddf1033
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 21, 2024
16c7976
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 23, 2024
13c7522
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jan 24, 2024
a5b0eae
FIX: GetTime func scale
Paliak Jan 29, 2024
88fab37
FEAT: impl save options. Allows for saving full output to xml.
Paliak Jan 29, 2024
5848348
FIX: docker compose exit code propagation
Paliak Jan 29, 2024
2df962b
FIX: nil deref when save options are not specified.
Paliak Jan 29, 2024
3faf02e
FEAT: impl build download throttling.
Paliak Jan 29, 2024
b62d55a
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Feb 2, 2024
a15d7e7
FIX: attempt to fix exit-code-from switch missing on gh.
Paliak Feb 2, 2024
d16e0ed
Merge branch 'dev' of https://github.com/Paliak/PathOfBuilding into dev
Paliak Feb 2, 2024
86656df
FIX: name comflicts in DFS stat traversal.
Paliak Feb 11, 2024
b424234
FIX: format xml into canonical form before diff.
Paliak Feb 11, 2024
14e9317
FIX: only print the header if there's a diff to display.
Paliak Feb 11, 2024
dba3a8f
FEAT: upload the diff output as an artefact in gha.
Paliak Feb 11, 2024
4c9b6fb
FIX: tests failing
Paliak Feb 11, 2024
cb8f0ec
FEAT: wrap diff output in markdown block.
Paliak Feb 11, 2024
04d1996
FEAT: rework buildDiff.sh
Paliak Feb 11, 2024
2701fdd
FIX: fill output not being included in xml for test output.
Paliak Feb 12, 2024
213ee29
FIX: different approach of avoiding creation of an emppty artefact.
Paliak Feb 12, 2024
c27c0b7
FIX: artefact creation. Log artefact contents.
Paliak Feb 12, 2024
c04c3c0
FIX: another attampt at fixing artefact generation
Paliak Feb 13, 2024
33ca340
FIX: sort player and minion stats to prevent stats from moving arounud
Paliak Feb 15, 2024
325b1ff
FIX: nil compare
Paliak Feb 15, 2024
57f4c51
FIX: allow empty git patch
Paliak Feb 16, 2024
3dec1b2
FIX: download cache not working. GenerateBuild.lua formatting.
Paliak Feb 16, 2024
ef37476
FIX: use the same version of luajit as new SG.
Paliak Feb 23, 2024
84de79b
FIX: remove batching.
Paliak Feb 23, 2024
5fd5da7
FIX: exit code not propagating up the call chain
Paliak Feb 23, 2024
cd9640d
Revert "FIX: use the same version of luajit as new SG."
Paliak Feb 23, 2024
b80b4c5
Revert "FIX: remove batching."
Paliak Feb 23, 2024
7842581
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Mar 1, 2024
c78ad3b
FEAT: add output only diff.
Paliak Mar 1, 2024
b049b8d
FIX: rename folder as it actually contains headref
Paliak Mar 2, 2024
a5a7df8
FIX: stricter download limits
Paliak Mar 4, 2024
197f897
FIX: curl user agent
Paliak Mar 4, 2024
8394e2f
FIX: staged changes to tests code not applying to devref.
Paliak Mar 8, 2024
6d55153
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Mar 25, 2024
82248ec
FEAT: tweaks to existing workflows
Paliak Mar 25, 2024
469115d
FEAT: add automatic test build list update
Paliak Mar 25, 2024
ed84520
FIX: yaml formatting
Paliak Mar 26, 2024
7d1fa2a
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Apr 8, 2024
11015db
Merge remote-tracking branch 'POB/dev' into dev
Paliak Jun 28, 2024
4e94dfa
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jun 28, 2024
c040cb8
FIX: flipped arguments dev<-->head
Paliak Jun 28, 2024
d8422a8
FIX: specify latest version in the compose file
Paliak Jun 28, 2024
6ceb81f
Merge branch 'dev' of https://github.com/Paliak/PathOfBuilding into dev
Paliak Jun 28, 2024
6f4d79b
WIP: testing builds.txt update logic
Paliak Jun 28, 2024
0ca6d01
FIX: Export newly generated build list an an artefact. Use 3rd party …
Paliak Jun 29, 2024
79d00f0
FEAT: implement build xml caching independent from dev ref cache.
Paliak Jun 29, 2024
f493e49
FIX: yaml formatting. remove unnecessary repo name check.
Paliak Jun 29, 2024
029c980
WIP: initial work on artitrary branch diffing
Paliak Jun 30, 2024
456e84e
FEAT: Add note to image if not ran through docker compose.
Paliak Jun 30, 2024
6f97050
FIX: link
Paliak Jun 30, 2024
b6b8822
WIP: more work on arbitrary brancch diffing
Paliak Jun 30, 2024
7d419fe
FIX: only fetch origin/dev
Paliak Jul 1, 2024
ab7489e
FIX: Make the dev ref cache an artefact. Make tests that use dev ref …
Paliak Jul 1, 2024
c01d4d4
FIX: origin/dev is not found. Pull all.
Paliak Jul 1, 2024
85ed5c9
FIX: make sure the /tmp/cache directory exists
Paliak Jul 1, 2024
da8e447
FIX: try fetching only dev
Paliak Jul 1, 2024
9c06352
FIX: If the last run used cache it will not re export the same cache …
Paliak Jul 1, 2024
aa34d46
FIX: Minor security improvements.
Paliak Jul 1, 2024
c7490f6
FXI: use the correct option to look for last avilable artefact.
Paliak Jul 1, 2024
3fe71e0
FEAT: implement runtime comparison. Some formatting.
Paliak Jul 2, 2024
f959c17
FIX: missing string concat
Paliak Jul 2, 2024
2bb9f22
FIX: flipped start time and current time
Paliak Jul 2, 2024
e39e791
FIX: add runtime performance to artefact. less-than -> greater -> than
Paliak Jul 2, 2024
8485b2b
FIX: directory exists error when downloadnig newest built list.
Paliak Jul 2, 2024
30057bd
FIX: mangled sed command
Paliak Jul 2, 2024
436b4c1
FIX: DiffRuntime.lua exit code. Percentage being printed as float
Paliak Jul 2, 2024
0e635ab
FIX: missing round bracket
Paliak Jul 2, 2024
768f136
DOCS: update docs to better reflect current testing implementation
Paliak Jul 3, 2024
4e8861c
FIX: spelling
Paliak Jul 10, 2024
edf53f6
FIX: specifty a path for artefact download action in update list
Paliak Jul 10, 2024
04dfbed
FIX: quote cron string
Paliak Jul 10, 2024
929fb8d
FIX: return the full list of static build link to builds.txt and use it
Paliak Jul 11, 2024
f2ff705
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jul 13, 2024
8ffcee2
FIX: ambiguous branch error
Paliak Jul 13, 2024
aa107d2
Merge branch 'dev' of https://github.com/Paliak/PathOfBuilding into dev
Paliak Jul 13, 2024
a12d49b
Merge branch 'dev' into dev
Paliak Jul 17, 2024
526a34a
FEAT: initial work on formatting/linting/coverage tooling support
Paliak Jul 18, 2024
199e05c
Merge branch 'dev' of https://github.com/Paliak/PathOfBuilding into dev
Paliak Jul 18, 2024
562acc9
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jul 18, 2024
ab4e908
Merge branch 'dev' of https://github.com/Paliak/PathOfBuilding into dev
Paliak Jul 18, 2024
b64a077
FIX: dockerfile luarocks install
Paliak Jul 18, 2024
7efa325
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jul 22, 2024
7a119f7
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Jul 28, 2024
71f7a82
Merge remote-tracking branch 'POB/dev' into dev
Paliak Aug 3, 2024
a34de95
Merge branch 'PathOfBuildingCommunity:dev' into dev
Paliak Aug 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
name: Push beta branch
on:
on:
schedule:
- cron: '0 0 * * 5'
push:
branches:
- 'master'
- master
workflow_dispatch:
jobs:
push-beta:
if: github.repository == 'PathOfBuildingCommunity/PathOfBuilding'
runs-on: ubuntu-22.04
steps:
- name: Set line endings
run: git config --global core.autocrlf true
- name: Checkout
uses: actions/checkout@v3
with:
ref: 'dev'
- name: Configure bot user
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Update manifest.xml
run: python3 update_manifest.py --quiet --in-place
- name: Push to beta branch
run: |
git commit -am "Weekly beta release" --allow-empty --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
git push origin HEAD:beta --force
- name: Set line endings
run: git config --global core.autocrlf true
- name: Checkout
uses: actions/checkout@v3
with:
ref: dev
- name: Configure bot user
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Update manifest.xml
run: python3 update_manifest.py --quiet --in-place
- name: Push to beta branch
run: |
git commit -am "Weekly beta release" --allow-empty --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
git push origin HEAD:beta --force
42 changes: 42 additions & 0 deletions .github/workflows/builddocker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and publish busted tests docker image
on:
workflow_dispatch:
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Generate docker image metadata
uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/${{ github.repository_owner }}/busted-tests
labels: |
org.opencontainers.image.description=A docker image packaged with the correct verions of tools to run PathOfBuilding busted tests. Includes emmylua debugger files. Refer to https://github.com/${{ github.repository_owner }}/PathOfBuilding/blob/tests-rework/CONTRIBUTING.md#setting-up-a-development-environment for usage instructions.
org.opencontainers.image.licenses=https://opensource.org/licenses/MIT
tags: |
type=sha
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
93 changes: 93 additions & 0 deletions .github/workflows/buildtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
name: Run Tests
on:
pull_request:
branches:
- dev
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
run_build_diff:
runs-on: ubuntu-latest
steps:
- name: Checkout HEAD
uses: actions/checkout@v4
- name: Fetch Dev branch
id: get-dev-ref
run: |
git fetch --depth=1 origin dev
echo "devref=$(git rev-parse origin/dev)" >> $GITHUB_OUTPUT
- name: Download Dev branch cache
id: download-dev-ref-cache
uses: dawidd6/action-download-artifact@3ecf4024886f219d9290351234889bfb45d1b9da
with:
name: cache-devref-${{ steps.get-dev-ref.outputs.devref }}
path: /tmp/cache/
if_no_artifact_found: warn
search_artifacts: true
# Dev ref cache contains the build list and build xmls. Use that one to keep tests reproducible
- name: Update static builds list from cache
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'true' }}
run: cat /tmp/cache/builds.txt > spec/builds.txt
- name: Download latest build list
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'false' }}
id: download-build-list
uses: dawidd6/action-download-artifact@3ecf4024886f219d9290351234889bfb45d1b9da
with:
name: builds.txt
path: /tmp/latestbuildlist/
workflow: updatebuildlist.yml
if_no_artifact_found: warn
search_artifacts: true
- name: Update static builds list
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'false' && steps.download-build-list.outputs.found_artifact == 'true' }}
run: cat /tmp/latestbuildlist/builds.txt > spec/builds.txt
- name: Download latest build xmls
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'false' }}
uses: dawidd6/action-download-artifact@3ecf4024886f219d9290351234889bfb45d1b9da
with:
name: build-xmls
path: /tmp/cache/
if_no_artifact_found: warn
search_artifacts: true
- name: Calculate build xmls and differences between them
run: |
mkdir /tmp/cache || true # Make sure /tmp/cache exists. Ignore exit code
chmod -R 777 /tmp/cache && docker compose run -v '/tmp/cache/:/cache' -e 'CACHEDIR=/cache' busted-diff | tee /tmp/dockerlog
- name: Generate artefact
run: |
sed -n '/Runtime comparison for/,/Savefile Diff for/{/Savefile Diff for/!p;}' /tmp/dockerlog > /tmp/artefact
sed -n '/Savefile Diff for/, $p' /tmp/dockerlog >> /tmp/artefact
[ -s /tmp/artefact ] || rm /tmp/artefact
- name: Upload artefact
uses: actions/upload-artifact@v4
with:
name: build-diff-output
path: /tmp/artefact
- name: Save used build list into cache
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'false' }}
run: cp spec/builds.txt /tmp/cache/
- name: Move xmls found in builds.txt to a new directory
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'false' && steps.download-build-list.outputs.found_artifact == 'true' }}
run: |
mkdir new-build-xmls
while IFS= read -r line; do
FILENAME="/tmp/cache/${line//[^a-zA-Z0-9]/}.xml"
if [ -f "$FILENAME" ]; then
mv "$FILENAME" "./new-build-xmls/"
fi
done < "spec/builds.txt"
- name: Upload new build xmls
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'false' && steps.download-build-list.outputs.found_artifact == 'true' }}
uses: actions/upload-artifact@v4
with:
name: build-xmls
path: './new-build-xmls/*'
- name: Upload dev ref cache
if: ${{ steps.download-dev-ref-cache.outputs.found_artifact == 'false' }}
uses: actions/upload-artifact@v4
with:
name: cache-devref-${{ steps.get-dev-ref.outputs.devref }}
path: /tmp/cache/
28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Run Unit Tests
on:
workflow_dispatch:
push:
branches:
- dev
pull_request:
branches:
- dev
jobs:
run_unit_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run busted tests
run: docker compose run --no-TTY busted-tests
37 changes: 37 additions & 0 deletions .github/workflows/updatebuildlist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Update build list for tests
on:
schedule:
- cron: '20 4 * * *'
workflow_dispatch:
jobs:
update-builds-list:
runs-on: ubuntu-22.04
steps:
- name: Checkout HEAD
uses: actions/checkout@v4
- name: Install moreutils
run: sudo apt-get install -y moreutils
- name: Download latest build list
uses: dawidd6/action-download-artifact@3ecf4024886f219d9290351234889bfb45d1b9da
with:
name: builds.txt
if_no_artifact_found: warn
path: /tmp/latestbuildlist/
- name: Update list
run: >
cat spec/builds.txt /tmp/latestbuildlist/builds.txt
<({ curl "https://pobarchives.com/api/builds?q=latest" & curl "https://pobarchives.com/api/builds?q=trending"; }
| jq -r '.builds[].build_info.build_link')
| tail -n 500
| sort -u
| sponge builds.txt
- name: Print new builds list
run: cat builds.txt
- name: Save new build list
uses: actions/upload-artifact@v4
with:
name: builds.txt
path: builds.txt
overwrite: true
retention-days: 3
8 changes: 8 additions & 0 deletions .lua-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
column_limit: 160
indent_width: 1
use_tab: true
tab_width: 4
continuation_indent_width: 4
spaces_before_call: 1
keep_simple_control_block_one_line: false
keep_simple_function_one_line: false
4 changes: 4 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
globals = { "round", "modLib", "LoadModule", "data", "ModFlag", "KeywordFlag", "SkillType", "launch", "IsKeyDown", "copyTable", "main", "colorCodesA"}
read_globals = {"DrawString", "SetDrawLayer", "GetDrawLayer", "ConPrintf", "SetDrawColor", "DrawStringWidth", "GetCursorPos", "SetViewport", "GetTime", "DrawImage", "NewFileSearch", "MakeDir"}
max_line_length = false
exclude_files = { "src\\TreeData", "src\\Data"}
48 changes: 26 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Feature requests are always welcome. Note that not all requests will receive an
### When submitting a pull request:
* **Pull requests must be created against the `dev` branch**, as all changes to the code are staged there before merging to `master`.
* Make sure that the changes have been thoroughly tested!
* Make sure not to commit `./src/Data/ModCache.lua`. This is a very large, automatically generated file that is updated in the repository for releases only.
* Make sure to commit `./src/Data/ModCache.lua` if your changes cause it to differ. This will generally be caused by editing `./src/Modules/ModParser.lua`.
* There are many more files in the `./src/Data` directory that are automatically generated. This is indicated by the header
`-- This file is automatically generated, do not edit!`. To change these, instead change the scripts in the `./src/Export` directory and rerun the exporter.
For your PR, please include all relevant changes to both the scripts and data files.
Expand Down Expand Up @@ -158,7 +158,7 @@ To do this in VSCode find the Java installation folder on your computer as displ
-- This is the path to emmy_core.dll. The ?.dll at the end is intentional.
package.cpath = package.cpath .. ";C:/Users/someuser/.vscode/extensions/tangzx.emmylua-0.5.19/debugger/emmy/windows/x64/?.dll"
local dbg = require("emmy_core")
-- This port must match the Visual Studio Code configuration. Default is 9966.
-- This port must match the IDE configuration. Default is 9966.
dbg.tcpListen("localhost", 9966)
-- Uncomment the next line if you want Path of Building to block until the debugger is attached
--dbg.waitIDE()
Expand Down Expand Up @@ -200,34 +200,38 @@ If you're on windows, consider downloading [git for windows](https://git-scm.com

If you're using linux you can run the ./runtime/Path{space}of{space}Building.exe executable with wine. You will need to provide a valid wine path to the emmy lua debugger directory.


## Testing
Pob uses two types of tests. Unit tests that test specific calculations or mechanics and "build diff" tests that calculate the effect the changes have on a given list of builds.
While both can be ran locally it's recommended to use the provided docker image for both ease of use and to keep everyone on the same page.

PoB uses the [Busted](https://olivinelabs.com/busted/) framework to run its tests. Tests are stored under `spec/System` and run automatically when a PR is modified.
More tests can be added to this folder to test specific functionality, or new test builds can be added to ensure nothing changed that wasn't intended.

### Running tests
1. Install [LuaRocks](https://luarocks.org/)
2. Run `luarocks install busted`
3. Run `busted --lua=luajit` from the command line. You may need to add `luajit` to your PATH
To run the unit tests run `docker compose up busted-tests`. This option uses the [Busted](https://olivinelabs.com/busted/) framework to test values returned by specific functions. For more details see the implementation of the tests in `spec/System/`.

Docker alternative:
To run the build difference tests run `docker compose up busted-diff`. `busted-diff` busted diff first computes a list of builds found in `spec/builds.txt` and `spec/TestBuilds/` while checked out to the current working changes. Then it uses git to checkout the branch specified by `DEVREF` or `dev` by default and computes the same builds. Lastly it finds the differences in the outputs generated from both, does some post processing, and prints all of the information out.

1. Install [Docker](https://www.docker.com/get-started)
2. Run `docker-compose up -d` from the command line
3. View last results in `spec/test_results.log`
`busted-diff` supports the following options through environment variables:
- `DEVREF`: Defines the branch to use as the reference against which to compare builds computed with new changes.
- `HEADREF`: Defines the branch which contains the changes to be tested.

### Creating new test builds or fixing an existing build
The following variables are meant to be internal only and only ever used with the `-e` option of docker compose, but are worth documenting nevertheless:
- `CACHEDIR`: Defines the directory where the cache of computed builds using `DEVREF` should be stored.

Sometimes a change will be made that intends to change the stats garnered by PoB, which will break our tests.
1. Add the new build XML (if applicable) to the `TestBuilds` folder
2. Run `busted --lua=luajit -r generate` to generate a LUA file that contains the current stats of that build
3. Run `busted --lua=luajit` and the tests should pass
#### Saving output
By default the output is not saved to a file but you can do so some your shell by either using `docker compose up busted-tests > log` (platform agnostic) or `docker compose up busted-tests | tee log` which will also allow you to see the output as it's being printed out (powershell/linux).

Docker alternative:
Additionally, the output from `busted-diff` can be quite noisy. If you'd like to only get a specific part of the output you can use to following:
- `sed -n '/Runtime comparison for/,/Savefile Diff for/{/Savefile Diff for/!p;}' log` to only print out runtime information or nothing if nothing interesting is to be shown.
- `sed -n '/Savefile Diff for/, $p' /tmp/dockerlog` to print out parsed output mismatch information as well as raw text diff of the generated build xml.

1. Add the new build XML (if applicable) to the `TestBuilds` folder
2. Run `docker-compose up -d` to generate a LUA file that contains the current stats of that build and run the tests
### Debugging tests
When running tests with a docker container it is possible to use emmylua for debugging. Paste in the following right under `function launch:OnInit()` in `./src/Launch.lua`:
```lua
package.cpath = package.cpath .. ";/usr/local/bin/?.so"
local dbg = require("emmy_core")
-- This port must match the IDE Code configuration. Default is 9966.
dbg.tcpListen("localhost", 9966)
dbg.waitIDE()
```
After running `docker-compose up busted-tests` the code will wait at the `dbg.waitIDE()` line until a debugger is attached. This will allow stepping through any code that is internal to POB but will not work for busted related code. Note that this only works for unit tests described above.

## Path of Building development tutorials

Expand Down
Loading