max-mapper / max-mapper/tape-spawn

handle multi process output comparison cleanly

Open
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
23
Forks
3
PR merge metrics
No merged PRs in 30d

Description

lately I've been having to write code like this:

``` js
function compareStatuses (t, dat1, dat2) {
// get dat1 'dat status' json
var st1 = spawn(t, dat + ' status --json', {cwd: dat1, end: false})
var status1

// get dat1 'dat status' json
st1.stdout.match(function (output) {
try {
JSON.parse(output)
status1 = output
return true
} catch (e) {}
}, 'status 1 is json')

// get dat2 'dat status' json, should be equal to dat1
st1.end(function () {
var st2 = spawn(t, dat + ' status --json', {cwd: dat2})
st2.stdout.match(function (output) {
try {
JSON.parse(output)
t.equal(status1, output, dat2 + ' status should match ' + dat1)
return status1 === output
} catch (e) {}
}, 'status1 matches status2')
st2.end()
})
}
```

it would be nice if:
- instead of putting the JSON.parse in a try/catch there was a builtin json specific thing that was a one-liner
- instead of having to do `end: false` on the first one, and put the 2nd one in the `.end` of the first, if the flow control provided by tape-spawn was more elegant
- when the test fails it doesn't print both sides output, because the 2nd assertion is not aware it is doing a comparison. I could put it in the `t.equal` I added in to the 2nd one, but that makes the output noisy when it passes

API suggestions welcome

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the tape-spawn implementation and tests for stdout matching, process completion, and assertion reporting. Compare those entry points with the three requested behaviors: JSON-aware matching, cleaner sequencing of spawned processes, and comparison-aware failure output. Done means an agreed API with coverage for each behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.