diff --git a/crates/kernel/src/tasks/mod.rs b/crates/kernel/src/tasks/mod.rs index 436aa6d4..95464210 100644 --- a/crates/kernel/src/tasks/mod.rs +++ b/crates/kernel/src/tasks/mod.rs @@ -296,7 +296,6 @@ pub mod scheduler_test_utils { player: &Obj, command: &str, ) -> Result { - eprintln!("call_command: {}", command); execute(|| scheduler.submit_command_task(&SYSTEM_OBJECT, player, command, session)) } @@ -306,7 +305,6 @@ pub mod scheduler_test_utils { player: &Obj, code: String, ) -> Result { - eprintln!("call_eval: {}", code); execute(|| { scheduler.submit_eval_task(player, player, code, session, FeaturesConfig::default()) }) diff --git a/crates/kernel/src/tasks/task.rs b/crates/kernel/src/tasks/task.rs index af957449..2218d3a7 100644 --- a/crates/kernel/src/tasks/task.rs +++ b/crates/kernel/src/tasks/task.rs @@ -305,7 +305,11 @@ impl Task { return None; }; - warn!(task_id = self.task_id, "Task exception"); + warn!( + task_id = self.task_id, + msg = exception.msg, + "Task exception" + ); self.vm_host.stop(); task_scheduler_client.exception(exception); diff --git a/crates/kernel/testsuite/README.md b/crates/kernel/testsuite/README.md index 0e77e761..2204739d 100644 --- a/crates/kernel/testsuite/README.md +++ b/crates/kernel/testsuite/README.md @@ -2,40 +2,49 @@ This is mostly a port of (part of) the regression suite bundled with Stunt MOO: https://github.com/toddsundsted/stunt/tree/master/test -| Status | `stunt` test(s) | `moor` test(s) | Notes | -| ------ | ---------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------- | -| ✅ | `test_algorithms.rb` | `algorithms.moot` | `stunt` added multiple hashing algorithms (not supported in `moor`). Fuzz tests not ported. | -| 🚫 | `test_anonymous.rb` | N/A | `moor` doesn't support anonymous objects. | -| ✅ | `test_basic.rb`, `basic/*` | `basic/*.moot` | | -| 🔜 | `test_canned_dbs.rb` | N/A | | -| 🤔 | `test_collection_improvements.rb` | N/A | Are these tests valuable / relevant for `moor`? | -| ✅ | `test_create.rb` | `create.moot` | | -| ✅ | `test_equality.rb` | `equality.moot` | | -| ✅ | `test_eval.rb` | `eval/*.moot` | | -| 🚫 | `test_exec.rb` | N/A | `moor` doesn't support this Stunt extension. | -| 🚫 | `test_fileio.rb` | N/A | `moor` doesn't support this Stunt extension. | -| 🚫 | `test_garbage_collection.rb` | N/A | `moor` doesn't support this Stunt extension. | -| 🚫 | `test_http.rb` | N/A | `moor` doesn't support this Stunt extension. | -| ✅ | `test_huh.rb` | `huh.moot` | See also `huh` test in the `telnet-host` crate. | -| 🚫 | `test_index_and_range_extensions.rb` | N/A | `moor` doesn't support this Stunt extension. | -| 🚫 | `test_json.rb` | N/A | `moor` doesn't support this Stunt extension. | -| 🔜 | `test_limits.rb` | N/A | | -| ✅ | `test_looping.rb` | `looping.moot` | | -| ✅ | ️`test_map.rb` | `map.moot` | | -| ✅ | `test_math.rb` | `math.moot` | | -| 🚫 | `test_miscellaneous.rb` | N/A | `moor` doesn't support this Stunt extension (`isa`) | -| ✅ | `test_moocode_parsing.rb` | N/A | Dropped tests for Stunt extensions (`^` collection, bitwise operators) | -| 🔜 | `test_objects.rb` | N/A | | -| 🔜 | `test_objects_and_properties.rb` | N/A | | -| 🔜 | `test_objects_and_verbs.rb` | N/A | | -| 🔜 | `test_primitives.rb` | N/A | | -| ✅ | `test_recycle.rb` | `recycle.moot` | | -| 🔜 | `test_stress_objects.rb` | N/A | | -| ✅ | `test_string_operations.rb` | `string_operations.moot` | Extended with cases based on LambdaMOO Programmer's Manual | -| 🚫 | `test_switch_player.rb` | N/A | `moor` doesn't support this Stunt extension. | -| 🚫 | `test_system_builtins.rb` | N/A | `moor` doesn't support this Stunt extension (`getenv`). | -| 🔜 | `test_task_local.rb` | N/A | | -| 🔜 | `test_things_that_used_to_crash_the_server.rb` | N/A | Probably useful to test these, since they were tricky for another server at somepoint | -| 🚫 | `test_verb_cache.rb` | N/A | `moor` doesn't support this Stunt extension. | +| Status | `stunt` test(s) | `moor` test(s) | Notes | +| ------ | ---------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------- | +| ✅ | `test_algorithms.rb` | `algorithms.moot` | `stunt` added multiple hashing algorithms (not supported in `moor`). Fuzz tests not ported. | +| 🚫 | `test_anonymous.rb` | N/A | `moor` doesn't support anonymous objects. | +| ✅ | `test_basic.rb`, `basic/*` | `basic/*.moot` | | +| 🔜 | `test_canned_dbs.rb` | N/A | | +| 🤔 | `test_collection_improvements.rb` | N/A | Are these tests valuable / relevant for `moor`? | +| ✅ | `test_create.rb` | `create.moot` | | +| ✅ | `test_equality.rb` | `equality.moot` | | +| ✅ | `test_eval.rb` | `eval/*.moot` | | +| 🚫 | `test_exec.rb` | N/A | `moor` doesn't support this Stunt extension. | +| 🚫 | `test_fileio.rb` | N/A | `moor` doesn't support this Stunt extension. | +| 🚫 | `test_garbage_collection.rb` | N/A | `moor` doesn't support this Stunt extension. | +| 🚫 | `test_http.rb` | N/A | `moor` doesn't support this Stunt extension. | +| ✅ | `test_huh.rb` | `huh.moot` | See also `huh` test in the `telnet-host` crate. | +| 🚫 | `test_index_and_range_extensions.rb` | N/A | `moor` doesn't support this Stunt extension. | +| 🚫 | `test_json.rb` | N/A | `moor` doesn't support this Stunt extension. | +| 🔜 | `test_limits.rb` | N/A | | +| ✅ | `test_looping.rb` | `looping.moot` | | +| ✅ | ️`test_map.rb` | `map.moot` | | +| ✅ | `test_math.rb` | `math.moot` | | +| 🚫 | `test_miscellaneous.rb` | N/A | `moor` doesn't support this Stunt extension (`isa`) | +| ✅ | `test_moocode_parsing.rb` | N/A | Dropped tests for Stunt extensions (`^` collection, bitwise operators) | +| 🚧 | `test_objects.rb` | `objects/{test_method}.moot` | See `test_objects` heading below | +| 🔜 | `test_objects_and_properties.rb` | N/A | | +| 🔜 | `test_objects_and_verbs.rb` | N/A | | +| 🔜 | `test_primitives.rb` | N/A | | +| ✅ | `test_recycle.rb` | `recycle.moot` | | +| 🔜 | `test_stress_objects.rb` | N/A | | +| ✅ | `test_string_operations.rb` | `string_operations.moot` | Extended with cases based on LambdaMOO Programmer's Manual | +| 🚫 | `test_switch_player.rb` | N/A | `moor` doesn't support this Stunt extension. | +| 🚫 | `test_system_builtins.rb` | N/A | `moor` doesn't support this Stunt extension (`getenv`). | +| 🔜 | `test_task_local.rb` | N/A | | +| 🔜 | `test_things_that_used_to_crash_the_server.rb` | N/A | Probably useful to test these, since they were tricky for another server at somepoint | +| 🚫 | `test_verb_cache.rb` | N/A | `moor` doesn't support this Stunt extension. | `.moot` files not mentioned above are not related to Stunt. + +## `test_objects` + +- `moor` doesn't support multiple inheritence. +- Stunt changes how `create()` behaves when arguments are not a valid object reference. `moor` follows the LambdaMOO behavior. + - https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb#L65-L75 + - https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb#L84-L94 + - https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb#L106-L111 + - https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb#L164-L169 diff --git a/crates/kernel/testsuite/moot/objects/test_create.moot b/crates/kernel/testsuite/moot/objects/test_create.moot new file mode 100644 index 00000000..b14b2660 --- /dev/null +++ b/crates/kernel/testsuite/moot/objects/test_create.moot @@ -0,0 +1,62 @@ +// Adapted from https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb +// def test_create + +@wizard +; add_property($system, "a", create($nothing), {$wizard_player, "rwc"}); +; add_property($system, "b", create($a), {$wizard_player, "rwc"}); +; add_property($system, "c", create($b, $nothing), {$wizard_player, "rwc"}); +; add_property($system, "d", create($b, $a), {$wizard_player, "rwc"}); + +// test that `parent()' works for single inheritance hierarchies +; return parent($a); +$nothing +; return parent($b); +$a +; return parent($c); +$b +; return parent($c); +$b + +// test that `children()' works for single inheritance hierarchies +; return children($a); +{$b} +; return children($b); +{$c, $d} +; return children($c); +{} +; return children($d); +{} + +// test that create sets the owner correctly +; return $a.owner; +$wizard_player +; return $b.owner; +$wizard_player +; return $c.owner; +$c +; return $d.owner; +$a + +; add_property($system, "e", create($nothing, $nothing), {$wizard_player, "rwc"}); +; add_property($system, "_f", create($nothing, $ambiguous_match), {$wizard_player, "rwc"}); +; add_property($system, "g", create($nothing, $failed_match), {$wizard_player, "rwc"}); +; add_property($system, "h", create($nothing, $invalid_object), {$wizard_player, "rwc"}); + +; return $e.owner; +$e +; return $_f.owner; +$ambiguous_match +; return $g.owner; +$failed_match +; return $h.owner; +$invalid_object + +@programmer +; create($nothing, $nothing); +E_PERM +; create($nothing, $ambiguous_match); +E_PERM +; create($nothing, $failed_match); +E_PERM +; create($nothing, $invalid_object); +E_PERM \ No newline at end of file diff --git a/crates/kernel/testsuite/moot/objects/test_create_errors.moot b/crates/kernel/testsuite/moot/objects/test_create_errors.moot new file mode 100644 index 00000000..59969d8e --- /dev/null +++ b/crates/kernel/testsuite/moot/objects/test_create_errors.moot @@ -0,0 +1,76 @@ +// Adapted from https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb +// def test_create_errors + +@wizard +; create(); +E_ARGS +; return create(1); +E_TYPE +; return create("1"); +E_TYPE +; return create(1, 2); +E_TYPE +; return create($object, "2"); +E_TYPE + +; create($ambiguous_match); +E_PERM +; create($failed_match); +E_PERM +; create($invalid_object); +E_PERM + +; return create({1}); +E_TYPE +; return create({"1"}); +E_TYPE +; return create({$nothing}); +E_TYPE +; return create({$ambiguous_match}); +E_TYPE +; return create({$failed_match}); +E_TYPE +; return create({$invalid_object}); +E_TYPE + +// A variety of tests that check permissions. + +; add_property($system, "a", create($nothing), {$wizard_player, "rwc"}); +; add_property($system, "b", create($a, $a), {$wizard_player, "rwc"}); +; $b.f = 1; +; return $a.owner; +$wizard_player +; return $b.owner; +$a + +@programmer +; create($a); +E_PERM +; create($b, $invalid_object); +E_PERM +; create($b, $wizard_player); +E_PERM +; create($b, $nothing); +E_PERM + +; return valid(create($b)); +1 + +; add_property($system, "c", create($nothing), {$programmer_player, ""}); +; add_property($system, "d", create($b, $programmer_player), {$programmer_player, "rwc"}); +; $d.f = 1; + +; return $c.owner; +$programmer_player +; return $d.owner; +$programmer_player + +@wizard +; return valid(create($a)); +1 +; return valid(create($b, $wizard_player)); +1 +; return valid(create($c, $programmer_player)); +1 +; return valid(create($d)); +1 \ No newline at end of file diff --git a/crates/kernel/testsuite/moot/single.moot b/crates/kernel/testsuite/moot/single.moot deleted file mode 100644 index 50a97820..00000000 --- a/crates/kernel/testsuite/moot/single.moot +++ /dev/null @@ -1,2 +0,0 @@ -; return -9223372036854775807; --9223372036854775808 + 1 \ No newline at end of file diff --git a/crates/kernel/testsuite/moot_suite.rs b/crates/kernel/testsuite/moot_suite.rs index cc396b58..f3fa4eaa 100644 --- a/crates/kernel/testsuite/moot_suite.rs +++ b/crates/kernel/testsuite/moot_suite.rs @@ -162,5 +162,5 @@ fn test(db: Box, path: &Path) { fn test_single() { // cargo test -p moor-kernel --test moot-suite test_single -- --ignored // CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --test moot-suite -- test_single --ignored - test_with_db(&testsuite_dir().join("moot/create.moot")); + test_with_db(&testsuite_dir().join("moot/objects/test_create.moot")); } diff --git a/crates/testing/moot/Test.db b/crates/testing/moot/Test.db index effd5ac8..dc2bc3a0 100644 --- a/crates/testing/moot/Test.db +++ b/crates/testing/moot/Test.db @@ -9,7 +9,7 @@ #0 System Object -16 +48 3 -1 -1 @@ -22,14 +22,20 @@ do_login_command 3 173 -1 -6 +12 nothing tmp tmp1 tmp2 system object -6 +invalid_object +ambiguous_match +failed_match +programmer_player +wizard_player +player +12 1 -1 3 @@ -54,6 +60,30 @@ object -1 3 7 +1 +2147483647 +3 +7 +1 +-2 +3 +7 +1 +-3 +3 +7 +1 +4 +3 +7 +1 +3 +3 +7 +1 +5 +3 +7 #1 Root Class @@ -130,21 +160,20 @@ nonprogrammer 0 #0:0 if (length(args) >= 2) - return eval("return " + args[2] + ";")[2]; +return eval(("return " + args[2]) + ";")[2]; else - return player; +return player; endif . #2:0 set_task_perms(player); try - notify(player, toliteral(eval(argstr + ";")[2])); -except err (ANY) - notify(player, toliteral(err[1])); +notify(player, toliteral(eval(argstr + ";")[2])); +except ERR (ANY) +notify(player, toliteral(ERR[1])); endtry . 0 clocks 0 queued tasks 0 suspended tasks -1 active connections with listeners -3 0 +0 active connections with listeners diff --git a/crates/testing/moot/Test.db.md b/crates/testing/moot/Test.db.md index 5cda9582..854477c6 100644 --- a/crates/testing/moot/Test.db.md +++ b/crates/testing/moot/Test.db.md @@ -7,11 +7,17 @@ Notable objects: - `#4`: programmer player - `#5`: non-programmer player -Globals: +Corified globals: - `$nothing`: `#-1` +- `$ambiguous_match`: `#-2` +- `$failed_match`: `#-3` - `$system`: `#0` +- `$wizard_player`: `#3` +- `$programmer_player`: `#4` +- `$player`: `#5` - `$object`, `$tmp`, `$tmp1`, `$tmp2`: for use as variables that persist across commands +- `$invalid_object`: `toobj(2142147483647)` Verbs: diff --git a/crates/testing/moot/tests/moot_lmoo.rs b/crates/testing/moot/tests/moot_lmoo.rs index 2dcd31a7..7e3c36c5 100644 --- a/crates/testing/moot/tests/moot_lmoo.rs +++ b/crates/testing/moot/tests/moot_lmoo.rs @@ -76,6 +76,7 @@ fn test_moo(path: &Path) { #[ignore = "Useful for debugging; just run a single test against 'real' MOO"] fn test_single() { test_moo( - &PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../kernel/testsuite/moot/truthiness.moot"), + &PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../kernel/testsuite/moot/objects/test_create_errors.moot"), ); }