Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Implement TestEZ CLI #61

Merged
merged 4 commits into from
Mar 4, 2020
Merged

Implement TestEZ CLI #61

merged 4 commits into from
Mar 4, 2020

Conversation

LPGhatguy
Copy link
Contributor

@LPGhatguy LPGhatguy commented Jan 24, 2020

This PR introduces a Rust tool into the TestEZ source tree named testez-cli. It embeds a copy of TestEZ inside itself and exposes an interface for running tests against projects.

The TestEZ CLI is intended as a replacement for the various scripts scattered all over the repositories we maintain. It's also supposed to be a parallel to the test runners that other frameworks like Busted and Jest offer.

This tool was previously known as "Testch" internally. We realized that this was a terrible name and also that it made more sense to integrate directly into the TestEZ codebase. This tool also aims to occupy a similar space to some other internal-only tools.

We chose Rust for this tool because Lua is not very suitable for writing a robust command line tool with, and requiring a scripting runtime makes deployingn and consuming tools difficult. Also, my team really likes Rust.

This CLI is going to be relatively opinionated about project structure. It assumes:

  • Your project's code is defined by either:
    • A default.project.json Rojo project file that builds your library or game.
    • In a directory called src (required for Lemur)
  • You manage dependencies by either:
    • Using Rotriever
    • Using Git submodules in a folder named modules
  • You want to run tests on one of the following platforms:
    • Roblox CLI (currently Roblox internal only)
      • roblox-cli must be on your PATH and you must have a production Roblox Studio installation.
    • Lemur
      • Lemur's dependencies (Lua 5.1 and luafilesystem) must be installed.
    • Roblox Studio
    • run-in-roblox

We plan in the future to expose configuration hooks for customizing the expected project layout for unique cases. We chose these requirements because they make this tool significantly simpler, already line up with conventions we use for open source projects at Roblox, and may help influence the ecosystem positively by pushing the community to standardize on project layout.

TODO

  • Lemur backend
  • Roblox Studio backend?
  • run-in-roblox backend?
  • CI and tests
  • Dependency type detection (Rotriever vs modules folder)

Copy link
Contributor

@ZoteTheMighty ZoteTheMighty left a comment

Choose a reason for hiding this comment

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

Mostly looks good! I had a couple questions here and there but the strategy seems sound to me. Might also want some sort of clear indication of what tools need to be installed to use this. Depending on target and your own project configuration, you might need some combination of lua, roblox-cli, and rojo.

RbxValue::BinaryString {
value: b"TestEZTestRoot".to_vec(),
},
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this tagging each child of the src folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This DOM code is pretty awkward. When models are deserialized from rbx_xml, a DataModel instance is constructed to hold all of the top-level instances from a model. This is a concession to the fact that models can have multiple top-level instances, but I didn't want the function to return multiple disjoint RbxTree instances.

This code ends up copying only one directory most of the time, usually src.

// If we're trying to run at core script security, disable
// the test runner script. It'll be loaded as a core script,
// and not disabling it will cause this code to also run at
// normal security.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this normal, or is it a bug in roblox-cli? Curious if the plan is to come back and change this later.

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'm not sure. This was the caveat that Anton gave me after he implemented the feature, but I think it would make sense to have roblox-cli do that for us.

//! Some parts of this code are used in the tool's build script mostly, while
//! other parts are used in the tool itself.

#![allow(unused)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something that you need when you only use something in a build.rs?

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 should document this file a little better!

I have #![allow(unused)] here since half the file is used only in build.rs and half of it is only used at runtime, but the structs are used in both cases. This is something that should be a crate, but I'm not sure it's polished enough yet.

@LPGhatguy
Copy link
Contributor Author

I tried to dump in a normal GitHub Actions Workflow before realizing that the build depends on Rojo.

We could use something like osyrisrblx/setup-rojo, but it only supports Linux right now. Maybe a little more forward-thinking solution would be to adopt Foreman 😄

@LPGhatguy
Copy link
Contributor Author

Multiple days later, and I've worked through the build issues on the machine and am successfully using Foreman to pull all of the build dependencies.

- Supports roblox-cli and Lemur targets

- Automatically detects Rotriever and Git submodules dependencies
@LPGhatguy LPGhatguy marked this pull request as ready for review March 2, 2020 19:11
@LPGhatguy LPGhatguy merged commit 6b356bd into Roblox:master Mar 4, 2020
@LPGhatguy LPGhatguy deleted the cli branch March 4, 2020 21:05
MagiMaster pushed a commit to MagiMaster/testez that referenced this pull request May 1, 2020
* Initial implementation of testez-cli

- Supports roblox-cli and Lemur targets

- Automatically detects Rotriever and Git submodules dependencies

* Back out bad merge?

* Switch to Rojo stable

* Update GitHub workflows and remove Travis config
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants