Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 56 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ on:
branches: [main]

jobs:
butterscotch-linux-x86_64:
name: Butterscotch Tests (GLFW/Linux x86_64)
build-linux-x86_64:
name: Build Butterscotch (GLFW/Linux x86_64)
runs-on: ubuntu-latest
env:
DOWNLOAD_COMMERCIAL_GAMES: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- uses: actions/checkout@v4

Expand All @@ -30,6 +28,30 @@ jobs:
- name: Build Butterscotch
run: cmake --build build -j$(nproc)

- name: Upload Butterscotch binary
uses: actions/upload-artifact@v4
with:
name: butterscotch-linux-x86_64
path: build/butterscotch

butterscotch-linux-x86_64:
name: Butterscotch Tests (GLFW/Linux x86_64)
runs-on: ubuntu-latest
needs: build-linux-x86_64
env:
DOWNLOAD_COMMERCIAL_GAMES: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- uses: actions/checkout@v4

- name: Download Butterscotch binary
uses: actions/download-artifact@v4
with:
name: butterscotch-linux-x86_64
path: build

- name: Mark Butterscotch binary executable
run: chmod +x build/butterscotch

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
Expand Down Expand Up @@ -71,3 +93,33 @@ jobs:
path: |
tests/**/actual.*.png
if-no-files-found: ignore

automated-ci-paths-linux-x86_64:
name: Automated CI Paths Test (GLFW/Linux x86_64)
runs-on: ubuntu-latest
needs: build-linux-x86_64
steps:
- uses: actions/checkout@v4

- name: Download Butterscotch binary
uses: actions/download-artifact@v4
with:
name: butterscotch-linux-x86_64
path: build

- name: Mark binaries and scripts executable
run: |
chmod +x build/butterscotch
chmod +x tests/automated-ci/paths/test.sh

- name: Run paths game and validate output
shell: bash
run: |
set -euo pipefail

test_path="${{ github.workspace }}/tests/automated-ci/paths/path_test"
binary="${{ github.workspace }}/build/butterscotch"
script="${{ github.workspace }}/tests/automated-ci/paths/test.sh"

timeout 120s "$script" "$binary" "$test_path"

8 changes: 8 additions & 0 deletions tests/automated-ci/paths/gm-project/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore .yy files for language statistics
*.yy linguist-generated=true

# force LF for metadata files for merge simplicity
*.gml text eol=lf
*.yy text eol=lf
*.yyp text eol=lf
*.json text eol=lf
35 changes: 35 additions & 0 deletions tests/automated-ci/paths/gm-project/Path Test.yyp

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

15 changes: 15 additions & 0 deletions tests/automated-ci/paths/gm-project/objects/Object1/Alarm_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
show_debug_message("===== DELETE =====");

path_delete(global.test_path);

show_debug_message("exists after delete = " + string(path_exists(global.test_path)));

show_debug_message("===== INVALID PATH =====");

var bad = 123456789;

show_debug_message("exists = " + string(path_exists(bad)));

show_debug_message("===== PATH TEST END =====");

game_end();
105 changes: 105 additions & 0 deletions tests/automated-ci/paths/gm-project/objects/Object1/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
show_debug_message("===== PATH TEST BEGIN =====");

function dump_path(p)
{
show_debug_message("-------------------------");
show_debug_message("exists = " + string(path_exists(p)));

if (!path_exists(p))
return;

show_debug_message("length = " + string(path_get_length(p)));
show_debug_message("points = " + string(path_get_number(p)));
show_debug_message("closed = " + string(path_get_closed(p)));
show_debug_message("kind = " + string(path_get_kind(p)));
show_debug_message("precision = " + string(path_get_precision(p)));

var n = path_get_number(p);

for (var i = 0; i < n; i++)
{
show_debug_message(
string(i)
+ ": x=" + string(path_get_point_x(p, i))
+ " y=" + string(path_get_point_y(p, i))
+ " speed=" + string(path_get_point_speed(p, i))
);
}

// Sample positions along the path
var samples = [0, 0.25, 0.5, 0.75, 1.0];

for (var i = 0; i < array_length(samples); i++)
{
var pos = samples[i];

show_debug_message(
"t=" + string(pos)
+ " -> x=" + string(path_get_x(p, pos))
+ " y=" + string(path_get_y(p, pos))
+ " speed=" + string(path_get_speed(p, pos))
);
}
}

// Create path

global.test_path = path_add();
var p = global.test_path;

show_debug_message("Created path id = " + string(p));

path_add_point(p, 64, 64, 100);
path_add_point(p, 256, 64, 200);
path_add_point(p, 256, 256, 300);
path_add_point(p, 64, 256, 400);

dump_path(p);

// Precision

show_debug_message("===== CHANGE PRECISION =====");

path_set_precision(p, 8);
dump_path(p);

// Kind

show_debug_message("===== CHANGE KIND =====");

path_set_kind(p, 1);
dump_path(p);

// Closed

show_debug_message("===== MAKE CLOSED =====");

path_set_closed(p, true);
dump_path(p);

// Clear

show_debug_message("===== CLEAR POINTS =====");

path_clear_points(p);

dump_path(p);

// Rebuild path for movement test

show_debug_message("===== REBUILD PATH =====");

path_add_point(p, 64, 64, 100);
path_add_point(p, 256, 64, 100);
path_add_point(p, 256, 256, 100);
path_add_point(p, 64, 256, 100);

dump_path(p);

// Create moving instance

instance_create_layer(64, 64, "Instances", obj_mover);

alarm[0] = room_speed * 3;

show_debug_message("===== PATH TEST READY =====");
36 changes: 36 additions & 0 deletions tests/automated-ci/paths/gm-project/objects/Object1/Object1.yy

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

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
path_start(global.test_path, 4, path_action_stop, false);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
show_debug_message(
"MOVE "
+ "x=" + string(x)
+ " y=" + string(y)
+ " path_position=" + string(path_position)
);
36 changes: 36 additions & 0 deletions tests/automated-ci/paths/gm-project/objects/obj_mover/obj_mover.yy

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

Loading
Loading