Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo cleaning and migration from munit to buddy. #55

Merged
merged 3 commits into from
Nov 3, 2020

Conversation

davidbruce
Copy link
Contributor

This is a large scale change that will simplify test generation from the problem specification repo.

New Testing Framework

Buddy is a BDD framework that does not rely on any external configuration files or auto generated classes like munit. A test suite all lives within a constructor of a class that extends buddy.SingleSuite.

Below is an example of translating two tests from canonical-data.json to tests for the Bob exercise.

canonical-data.json:

{
      "uuid": "e162fead-606f-437a-a166-d051915cea8e",
      "description": "stating something",
      "property": "response",
      "input": {
        "heyBob": "Tom-ay-to, tom-aaaah-to."
      },
      "expected": "Whatever."
    },
    {
      "uuid": "73a966dc-8017-47d6-bb32-cf07d1a5fcd9",
      "description": "shouting",
      "property": "response",
      "input": {
        "heyBob": "WATCH OUT!"
      },
      "expected": "Whoa, chill out!"
    },

Test.hx:

package;

using buddy.Should;

class Test extends buddy.SingleSuite {
    public function new() {
        describe("Bob", {
            final SURE     = "Sure.";
            final CHILL    = "Whoa, chill out!";
            final CALM     = "Calm down, I know what I'm doing!"; 
            final FINE     = "Fine. Be that way!";
            final WHATEVER = "Whatever.";

            it("stating something", {
                Bob.hey("Tom-ay-to, tom-aaaah-to.").should.be(WHATEVER);
            });
            it("shouting", {
                Bob.hey("WATCH OUT!").should.be(CHILL);
            });
        });
    }
}

Running the tests

The test.hxml files have all been updated as well to make use of the -x flag, so that files are generated and ran immediately on the NekoVM. This makes all of the makefiles that were previously used no longer necessary. Also all tests are now just named Test.hx to allow for a single test.hxml to be copied to all exercies. So, running tests is as easy as:

haxe test.hxml

test.hxml:

-x Test
-lib buddy 
-cp src/
-cp test/

Other issues fixed:

The EXERCISES.txt file was removed, since that doesn't appear in any other exercism tracks, so it may just be an old relic.
Fixed the Hello world example, it was missing a closing ", so it failed to compile.
Fixed the Bob example to pass all tests. It was missing the calm condition.
Fixed the Leap example, it looks like it was copied from javascript, so === and !== were replaced with != and ==.
Updated docs/TESTS.md

I have added all the required .meta/test.toml files making PR #51 redundant.
I have added topics and blurb to config.json for #7.
I have added the stub for bob requested in # #48 .

@ErikSchierboom Please let me know if there are any changes needed. Once this is moved in I'll submit a new PR with the majority of other exercises once I have the generator fully functional. If all is well with your review please just got ahead and merge it since I cannot.

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just some minor comments.

@@ -1,7 +1,7 @@
{
"language": "Haxe",
"active": false,
"blurb": "",
"blurb": "Haxe is an open source high-level strictly-typed programming language with a fast optimizing cross-compiler. Haxe can build cross-platform applications targeting JavaScript, C++, C#, Java, JVM, Python, Lua, PHP, Flash, and allows access to each platform's native capabilities. Haxe has its own VMs (HashLink and NekoVM) but can also run in interpreted mode. Code written in Haxe can be compiled to any target Haxe supports.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add the online_editor key? See https://github.com/exercism/csharp/blob/master/config.json#L5 for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the online_editor key.

it("stating something", {
Bob.hey("Tom-ay-to, tom-aaaah-to.").should.be(WHATEVER);
});
it("shouting", {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, tracks that support it have all tests ignored except for the first test. See for example the C# bob tests. The idea is that it forces students to solve tests one at a time, effectively engaging in TDD. Is this something that is supported by the test framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a pending call which will skip over a test. Then users can just comment it out to run the test.

            it("stating something", {
                Bob.hey("Tom-ay-to, tom-aaaah-to.").should.be(WHATEVER);
            });
            it("shouting", {
                pending("Skipping");
                Bob.hey("WATCH OUT!").should.be(CHILL);
            });
XPPPPPPPPPPPPPPPPPPPPPPPP
Bob
  stating something (FAILED)
    Not Implemented
      @ /home/davidbruce/Git/haxe/buddy/src/buddy/SuitesRunner.hx:519
      @ test/Test.hx:16
      @ src/Bob.hx:5
  shouting (Pending)
    test/Test.hx:19: Skipping
  shouting gibberish (Pending)
    test/Test.hx:23: Skipping
  asking a question (Pending)
    test/Test.hx:27: Skipping
  asking a numeric question (Pending)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would be great!

@davidbruce
Copy link
Contributor Author

@ErikSchierboom I've made the requested changes, go ahead and merge if you approve.

@ErikSchierboom ErikSchierboom merged commit 0813a72 into exercism:master Nov 3, 2020
@ErikSchierboom
Copy link
Member

@davidbruce I've just noticed that you're not yet in the maintainers.config file. Could you add yourself to that file? That will give you the appropriate permissions on this repo.

For an example of what an entry should look like, see https://github.com/exercism/csharp/blob/master/config/maintainers.json#L3

Nezteb pushed a commit to davidbruce/haxe that referenced this pull request Sep 18, 2023
* Migration from munit to buddy, updates config.json and adds tests.toml.

* Add online_editor to config.json

* Updates exercises to skip all but the first test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants