teambit / bit

A build system for development of composable software.
https://bit.dev
Other
17.88k stars 926 forks source link

add multiple tests files with glob pattern adding only the first test file #1637

Closed JoshK2 closed 5 years ago

JoshK2 commented 5 years ago

I want to run bit on this project https://github.com/petyosi/react-virtuoso and when I added the component with tests, the test files in .bitmap is not correct.

This is what I get:

{
    "relativePath": "test/AATree.test.ts",
    "test": true,
    "name": "AATree.test.ts"
},
{
    "relativePath": "test/OffsetList.test.ts",
    "test": false,
    "name": "OffsetList.test.ts"
},
{
    "relativePath": "test/VirtuosoStore.test.ts",
    "test": false,
    "name": "VirtuosoStore.test.ts"
}

Steps to Reproduce the Problem

  1. clone https://github.com/petyosi/react-virtuoso
  2. bit init
  3. bit add src -t test/* -i virtuoso

Specifications

davidfirst commented 5 years ago

I believe this is the second confusion I see about this in the recent two weeks. We should update the help to clarify this. The flags --test, --exclude do not support wildcards. They only support DSL ({PARENT} and {FILE_NAME} annotations).

Assuming you have the following file structure:

src/foo.js
src/bar.js
tests/foo.spec.js
tests/bar.spec.js

when you run bit add src -t tests/*, the CLI parses the wildcard and passes the following to Bit: bit add src tests/foo.spec.js -t tests/bar.spec.js.

The is a limitation of the CLI. You can't pass multiple values for the argument AND multiple values to a flag (--test in this case). In this case, because the tests/* is interpreted to multiple values: [ tests/foo.spec.js, tests/bar.spec.js ], it uses only one value for the --test flag, and the rest for the main argument of bit add. To pass multiple values to --test, you have to add them inside a quote so then they'll be considered as one value, then, Bit knows to split them and add them.

@itaymendel , we need to think about how to reflect that in the help. the current help says

all flags support glob patterns and {PARENT} {FILE_NAME} annotations

which is incorrect. The flags don't support wildcards.

GiladShoham commented 5 years ago

@davidfirst So they do support glob patterns / wildcards it just to be inside quotes. correct?

davidfirst commented 5 years ago

@GiladShoham , yes, that's is correct. I didn't remember implementing it, but I checked the code and found out that we run glob after resolving the DSL. That glob call resolves the wildcard. So, adding it into quotes works. It's important to add it to the help.

GiladShoham commented 5 years ago

Add this to help done on https://github.com/teambit/bit/pull/1646, merged.