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

test cli steps parsing #1833

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

daemon1024
Copy link
Member

Ref #1747

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with npm run test-all
  • code is in uniquely-named feature branch and has no merge conflicts
  • PR is descriptively titled
  • ask @publiclab/is-reviewers for help, in a comment below
  • Insert-step functionality is working correct as expected.

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Please make sure to get at least two reviews before asking for merging the PR as that would make the PR more reliable on our part
Thanks!

@daemon1024 daemon1024 requested a review from a team as a code owner March 7, 2021 22:32
@gitpod-io
Copy link

gitpod-io bot commented Mar 7, 2021

@daemon1024 daemon1024 marked this pull request as draft March 7, 2021 22:32
@daemon1024
Copy link
Member Author

I am facing a few roadblocks while making this test.

  1. I am not sure why node test/cli/*.js isn't running the newly created file.
  2. Even after using async/await it doesn't wait for the cli to stop processing, the program proceeds right after it warns about 'Output directory will remain empty till execution'
  3. When I try to read the error logs, it seems that the exit call stops the execution of test too.

Any kind of help appreciated

cc @jywarren @harshkhandeparkar

const test = require('tape');
const cli = require('../../src/cli');
const stdout = require('./util/readConsole').stdout;
const stderr = require('./util/readConsole').stderr;
Copy link
Member

Choose a reason for hiding this comment

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

This all looks ok, compared to

const test = require('tape');
const cli = require('../../src/cli');

const stdout = require('./util/readConsole').stdout;
const stderr = require('./util/readConsole').stderr;

test('testing steps parsing', async function (t) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth running it without async first to just see if the issue is related just to that?

Copy link
Member

Choose a reason for hiding this comment

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

and we're sure tape does async? I believe tape is pretty minimal so it may be worth looking in the tape docs.

Also, i notice the package.json config pipes the output to tape-spec, do we need to do that? Just wondering if you've tried that. Trying to get as close to the existing version as we can to diagnose the issues.

Copy link
Member

Choose a reason for hiding this comment

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

"test-cli": "node test/cli/*.js | tap-spec",

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it worth running it without async first to just see if the issue is related just to that?

and we're sure tape does async?

Tape works in async though it still fails, apparently cli function doesn't return a promise so there's no point of async/await anyway.

i notice the package.json config pipes the output to tape-spec, do we need to do that?

It's just a prettified/formatted output of the tape report, it shouldn't interfere with the output. But I tried it out without it and I am still facing same issues :(

@jywarren
Copy link
Member

Does node test/cli/steps.js work by itself? I'm pretty stumped too here, i wonder if it's something simple we're overlooking...

@daemon1024
Copy link
Member Author

daemon1024 commented Mar 12, 2021

Does node test/cli/steps.js work by itself?

Yup, I have attached the output below

I'm pretty stumped too here, i wonder if it's something simple we're overlooking...

Me too 😓

Here's the output, running *.js should match all the files, running steps.js individually does work.

$ node test/cli/*.js

TAP version 13
# testing save sequence function
 Your sequence was saved successfully!!
ok 1 creation success
ok 2 creation fail

1..2
# tests 2
# pass  2

# ok
$ node test/cli/steps.js 
TAP version 13
# testing steps parsing
Please wait 
 output directory generated will be empty until the execution is complete
ok 1 Steps parsed successfully

1..1
# tests 1
# pass  1

# ok

@daemon1024
Copy link
Member Author

Also I made the test pass by adding blocking code, but I don't think that would be the right way to proceed, what are your opinion about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants