Skip to content

Commit

Permalink
BREAKING: Removed the first argument of olympus_run(). Suite name i…
Browse files Browse the repository at this point in the history
…s now defined through the option `olympus_suite_options_suite_name`.
  • Loading branch information
shichen85 committed May 13, 2024
1 parent 624441c commit d1dd17c
Show file tree
Hide file tree
Showing 32 changed files with 461 additions and 180 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

⚠ This project is still in active development, and APIs are subject to change. ⚠

Testing framework for [GameMaker 2022.6+](https://gamemaker.io/en/blog/release-2022-6) projects with useful features:
Testing framework for [GameMaker 2024.4+](https://releases.gamemaker.io/release-notes/2024/4) projects with useful features:

- **Record Keeping** - Test results are recorded and json exportable
- **Crash Recovery** - Resume progress after runner crashes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"preversion": "git fetch --tags",
"version": "npx conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
"import": "npx stitch merge --source='E:/repos/GamePipe/Ganary/Ganary' --ifFolderMatches=Olympus -f",
"import": "npx stitch merge --source='E:/repos/Games/bscotch-pack/BscotchPack' --ifFolderMatches=Olympus_acceptance_test -f",
"postversion": "git push --follow-tags"
},
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/Olympus.yyp

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

9 changes: 4 additions & 5 deletions src/datafiles/Olympus/Olympus_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Compose your test suite:

```ts
//Name your test suite
olympus_run("my suite name", function () {
olympus_run(function () {
//Add a unit test
olympus_add_test(
//Name your unit test
Expand Down Expand Up @@ -90,7 +90,7 @@ The test suite summary data is a GML struct with the following shape:
"passed": 0,
"failed": 1
},
"name": "my_suite_name", //The suite name defined by `olympus_run(suite_name)`
"name": "my_suite_name",
"tests": [
//Array of unit test summaries. See [Unit Test Summary](#unit-test-summary)
]
Expand Down Expand Up @@ -297,7 +297,7 @@ olympus_add_async_test(
```ts
///Pt 5
olympus_run("My Suite Name", function(){
olympus_run(function(){
//Define the logic to spawn the async mediator object and return its instance ID
var mediator_spawning_logic = function(){
return instance_create_depth(0,0,0,obj_http_mediator)
Expand Down Expand Up @@ -431,7 +431,7 @@ Sometimes we may want to pass shared variables between unit tests. This is doabl
```ts
shared_variable_sum = 0;
olympus_run("shared variables test", function () {
olympus_run(function () {
olympus_add_test("sum should be 1", function () {
shared_variable_sum++;
show_debug_message(string(shared_variable_sum)); //1
Expand All @@ -453,7 +453,6 @@ Alternatively, you can explicitly define what variables the tests should have ac
```ts
not_explicitly_defined_variable = "goodbye";
olympus_run(
"shared variables from custom context test",
function () {
olympus_add_test("", function () {
show_debug_message(explicitly_shared_variable);
Expand Down
28 changes: 18 additions & 10 deletions src/extensions/_olympus_extension/AndroidSource/Java/Olympus.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@

import ${YYAndroidPackageName}.R;
import com.yoyogames.runner.RunnerJNILib;

import ${YYAndroidPackageName}.RunnerActivity;

import android.app.Activity;
import android.util.Log;
import android.content.Intent;

public class Olympus extends RunnerSocial
{
public class Olympus extends RunnerSocial {
public static Activity activity = null;
public static Intent launchIntent = null;

public void _olympus_android_init() {
Log.i("yoyo", "_olympus_android_init");
activity = RunnerActivity.CurrentActivity;
launchIntent = activity.getIntent();
public void _olympus_android_init() {
Log.i("yoyo", "_olympus_android_init");
activity = RunnerActivity.CurrentActivity;
launchIntent = activity.getIntent();
Log.i("yoyo", "launchIntent: " + launchIntent);
}
}

public void _olympus_android_game_end(){
public void _olympus_android_game_end() {
activity.finish();
}
}

public String _olympus_android_get_init_confirmation() {
return "initialized";
}

public String _olympus_android_get_intent() {
Log.i("yoyo", "getIntent");
return launchIntent.toString();
}
}
28 changes: 20 additions & 8 deletions src/extensions/_olympus_extension/_olympus_extension.yy

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

10 changes: 10 additions & 0 deletions src/extensions/_olympus_extension/iOSSource/Olympus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface Olympus : NSObject
{
}
- (void)_olympus_ios_finish_loop;
- (NSString *)_olympus_ios_get_init_confirmation;
- (NSString *)_olympus_ios_get_intent;
@end
25 changes: 25 additions & 0 deletions src/extensions/_olympus_extension/iOSSource/Olympus.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#import "Olympus.h"
#import "OlympusDelegate.h"
@implementation Olympus
- (void)_olympus_ios_finish_loop {

NSLog(@"_olympus_ios_finish_loop");
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:@"firebase-game-loop-complete://"]
options:@{}
completionHandler:^(BOOL success) {}];
}

- (NSString*) _olympus_ios_get_init_confirmation
{
NSString *value = @"initialized";
return value;
}


- (NSString*) _olympus_ios_get_intent
{
NSString *value = [OlympusDelegate get_intent];
return value;
}
@end
7 changes: 7 additions & 0 deletions src/extensions/_olympus_extension/iOSSource/OlympusDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import "iPad_RunnerAppDelegate.h"

@interface OlympusDelegate : iPad_RunnerAppDelegate
+ (NSString *)get_intent;


@end
38 changes: 38 additions & 0 deletions src/extensions/_olympus_extension/iOSSource/OlympusDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#import "OlympusDelegate.h"
@implementation OlympusDelegate

NSString *intent = @"uninitialized";

- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary *)options{
NSString *message = @"Hello, world!";
NSLog(@"%@", message);
if ([url.scheme isEqualToString:(@"firebase-game-loop")]) {
NSLog(@"launching in firebase");
intent = [url.scheme copy];
}
else{
NSLog(@"launching in normal mode");
intent = @"normal-launch";
}
}


- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{


// Check if any superclasses implement this method and call it
if([[self superclass] instancesRespondToSelector:@selector(application:willFinishLaunchingWithOptions:)])
return [super application:application willFinishLaunchingWithOptions:launchOptions];
else
return TRUE;
}

+ (NSString*) get_intent
{
return intent;
}

@end
37 changes: 23 additions & 14 deletions src/objects/_olympus_acceptance_test_starter/Other_10.gml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var olympus_register_acceptance_tests = function(){
_olympus_acceptance_test_expect_eq(test_starter_instance_variable_to_be_replaced_by_custom_context, expected_instance_var, "And custom context can override original context.");
}

olympus_add_test("P_current_index_test", function(){
olympus_add_test("P_current_index_test",function(){
if (_olympus_suite_ref.get_current_test()._index != 0) {
show_error("This test must be the 0th test!", true);
}
Expand Down Expand Up @@ -213,8 +213,8 @@ var olympus_register_acceptance_tests = function(){
}

if (suite_config == "Olympus_only_test"){
olympus_add_test("O_only_test", function(){}, {olympus_test_options_only: true})
olympus_add_test("O_only_test2", function(){}, {olympus_test_options_only: true})
olympus_add_test("O_only_test", function(){}, {olympus_test_options_only: true});
olympus_add_test("O_only_test2", function(){}).only();
}
else if (suite_config != "Olympus_bail"){
olympus_add_test("O_only_test3", function(){}, {olympus_test_options_only: true})
Expand Down Expand Up @@ -282,6 +282,7 @@ var olympus_register_acceptance_tests = function(){
});

olympus_add_hook_before_suite_start(function(summary){
_olympus_console_log("hook_before_suite_start is triggered");
_olympus_console_log(summary);
});

Expand Down Expand Up @@ -330,6 +331,8 @@ var olympus_register_acceptance_tests = function(){
break;
case "C":
expected_result = olympus_test_status_crashed;
var test_duration = the_test.millis;
_olympus_acceptance_test_expect_eq(1, test_duration, "Crashed test should set duration to 1");
break;
case "S":
expected_result = olympus_test_status_skipped;
Expand All @@ -347,7 +350,7 @@ var olympus_register_acceptance_tests = function(){
_olympus_acceptance_test_expect_eq(expected_result, actual_result, test_name);
}
}
show_debug_message(_olympus_suite_ref._suite_name + " passed!");
show_debug_message(_olympus_suite_ref.suite_name + " passed!");
});

//TODO: test the context for hooks
Expand All @@ -361,32 +364,34 @@ var olympus_register_acceptance_tests = function(){
}

try{
olympus_run("Olympus Forbid Only Test", olympus_register_acceptance_tests,
olympus_run(olympus_register_acceptance_tests,
{
olympus_suite_options_abandon_unfinished_record: _should_abandon_record,
olympus_suite_options_skip_user_feedback_tests: os_get_config() == "Olympus_dev",
olympus_suite_options_forbid_only: true,
olympus_suite_options_context: {suite_config: "Olympus_only_test"}
olympus_suite_options_context: {suite_config: "Olympus_only_test"},
olympus_suite_options_suite_name: "Olympus Forbid Only Test",
});
}
catch(err){
_olympus_acceptance_test_expect_eq(_olympus_suite_execution_error_forbid_only, err.message);
}

try{
olympus_run("Olympus Forbid Skip Test", olympus_register_acceptance_tests,
olympus_run(olympus_register_acceptance_tests,
{
olympus_suite_options_abandon_unfinished_record: _should_abandon_record,
olympus_suite_options_skip_user_feedback_tests: os_get_config() == "Olympus_dev",
olympus_suite_options_forbid_skip: true,
olympus_suite_options_context: {suite_config: "Olympus_only_test"}
olympus_suite_options_context: {suite_config: "Olympus_only_test"},
olympus_suite_options_suite_name: "Olympus Forbid Skip Test",
});
}
catch(err){
_olympus_acceptance_test_expect_eq(_olympus_suite_execution_error_forbid_skip, err.message);
}

olympus_run("Olympus Acceptance Test", olympus_register_acceptance_tests,
olympus_run(olympus_register_acceptance_tests,
{
olympus_suite_options_abandon_unfinished_record: _should_abandon_record,
olympus_suite_options_skip_user_feedback_tests: os_get_config() == "Olympus_dev",
Expand All @@ -396,24 +401,28 @@ olympus_run("Olympus Acceptance Test", olympus_register_acceptance_tests,
olympus_suite_options_global_timeout_millis: 400,
olympus_suite_options_context: {suite_config: "default", test_starter_instance_variable_to_be_replaced_by_custom_context: "replaced"},
olympus_suite_options_allow_uncaught: debug_mode && os_get_config() == "Olympus_dev",
olympus_suite_options_bypass_only: true
olympus_suite_options_bypass_only: true,
olympus_suite_options_allow_uncaught_silent_termination: true,
olympus_suite_options_suite_name: "Olympus Acceptance Test",
});

olympus_run("Olympus Bail Test", olympus_register_acceptance_tests,
olympus_run(olympus_register_acceptance_tests,
{
olympus_suite_options_abandon_unfinished_record: _should_abandon_record,
olympus_suite_options_skip_user_feedback_tests: os_get_config() == "Olympus_dev",
olympus_suite_options_bail_on_fail_or_crash: true,
olympus_suite_options_context: {suite_config: "Olympus_bail"}
olympus_suite_options_context: {suite_config: "Olympus_bail"},
olympus_suite_options_suite_name: "Olympus Bail Test",
});

olympus_run("Olympus Only Test", olympus_register_acceptance_tests,
olympus_run(olympus_register_acceptance_tests,
{
olympus_suite_options_abandon_unfinished_record: _should_abandon_record,
olympus_suite_options_skip_user_feedback_tests: os_get_config() == "Olympus_dev",
olympus_suite_options_bail_on_fail_or_crash: true,
olympus_suite_options_context: {suite_config: "Olympus_only_test"},
olympus_suite_options_exit_on_completion: true
olympus_suite_options_exit_on_completion: true,
olympus_suite_options_suite_name: "Olympus Only Test",
});

instance_destroy();
Loading

0 comments on commit d1dd17c

Please sign in to comment.