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

Replace tests/generator/*.xml with .js files #1142

Closed
AnmAtAnm opened this issue May 31, 2017 · 4 comments
Closed

Replace tests/generator/*.xml with .js files #1142

AnmAtAnm opened this issue May 31, 2017 · 4 comments
Labels

Comments

@AnmAtAnm
Copy link
Contributor

AnmAtAnm commented May 31, 2017

Our generator tests currently try to read XML directly, but this doesn't work in a local file environment (browser security limitation), such as exactly the environment developers are likely to want to use when they are editing and testing the code base.

Thankfully, there is an easy fix. Since the test code is not distributed with other apps, we can use JavaScript ES6 raw strings:

var testdata = String.raw`
<xml xmlns="http://www.w3.org/1999/xhtml">
  <block type="unittest_main" x="33" y="140">
    <statement name="DO">
      <block type="procedures_callnoreturn">
        <mutation name="test repeat"></mutation>
        <next>
          <block type="procedures_callnoreturn">
            <mutation name="test repeat_ext"></mutation>
            <next>
              <block type="procedures_callnoreturn">
`

Raw strings can use any character except the backtick, and we don't have that in our test files.

$ grep \` tests/generators/*.xml
# No results
$

As .js files, we can import all the testdata via script tags. The only down side is that it is the file is no longer XML, but given that the XML does not need to be escaped, this is pretty trivial to cut and paste if you really need to use a syntax highlighting editor or other XML tool.

The page will need to update how it is reading the target test data in response to the selector.

@moogacs
Copy link

moogacs commented Apr 10, 2019

@AnmAtAnm is this one still open ?

moogacs added a commit to moogacs/blockly that referenced this issue Apr 10, 2019
moogacs added a commit to moogacs/blockly that referenced this issue Apr 10, 2019
@AnmAtAnm
Copy link
Contributor Author

I think so, but check with @rachel-fenichel.

@rachel-fenichel
Copy link
Collaborator

Yes.

@maribethb
Copy link
Contributor

We now run the generator tests in a browser and we plan to continue to do so, therefore we don't need to implement this.

@maribethb maribethb closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants