Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

2 tests fail on just cloned repo #3443

Closed
M0ns1gn0r opened this issue Nov 2, 2017 · 11 comments
Closed

2 tests fail on just cloned repo #3443

M0ns1gn0r opened this issue Nov 2, 2017 · 11 comments

Comments

@M0ns1gn0r
Copy link
Contributor

Bug Report

  • TSLint version: master d1caf11
  • TypeScript version: 2.6.1
  • Running TSLint via: CLI (yarn test)

Actual behavior

I cloned the repo and followed the instructions in the readme, i.e. executed yarn compile and then yarn test. Two tests keep failing:

  ...

  137 passing (58s)
  2 failing

  1) Executable Files exits with code 0 if correct file is passed:
	 Uncaught AssertionError: process should exit without an error: expected [Error: Command failed: X:\tslint\test\executable\npm-like-executable.cmd src/configuration.ts
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
] to equal null
	  at Function.assert.isNull (node_modules\chai\lib\chai\interface\assert.js:407:32)
	  at build\test\executable\executableTests.js:52:31
	  at build\test\executable\executableTests.js:482:9
	  at ChildProcess.exithandler (child_process.js:213:5)
	  at maybeClose (internal/child_process.js:877:16)
	  at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

  2) Executable Files exits with code 0 if several files passed without `-f` flag:
	 Uncaught AssertionError: process should exit without an error: expected [Error: Command failed: X:\tslint\test\executable\npm-like-executable.cmd src/configuration.ts src/formatterLoader.ts
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
] to equal null
	  at Function.assert.isNull (node_modules\chai\lib\chai\interface\assert.js:407:32)
	  at build\test\executable\executableTests.js:58:31
	  at build\test\executable\executableTests.js:482:9
	  at ChildProcess.exithandler (child_process.js:213:5)
	  at maybeClose (internal/child_process.js:877:16)
	  at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Expected behavior

139 passing (60s)
@ajafff
Copy link
Contributor

ajafff commented Nov 2, 2017

I cannot reproduce this on Ubuntu 17.10
This must be specific to windows.

Please modify test/executableTests.ts at line 50 to hopefully get more useful output:

-execCli(["src/configuration.ts"], (err) => {
+execCli(["src/configuration.ts"], (err, stdout, stderr) => {
+    console.log(stdout);
+    console.log(stderr);
+    console.log(err);
     assert.isNull(err, "process should exit without an error");
     done();
 });

then run yarn compile and yarn test:mocha again

@M0ns1gn0r
Copy link
Contributor Author

I'm afraid nothing helpfull:

  Executable
	√ finds configuration above current directory
	Files
	  √ exits with code 1 if no arguments passed
ERROR: src/configuration.ts[1, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[2, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[3, 1]: Expected linebreak to be 'LF'
	... repeats for each line ...
ERROR: src/configuration.ts[523, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[524, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[525, 1]: Expected linebreak to be 'LF'
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
{ Error: Command failed: X:\tslint\test\executable\npm-like-executable.cmd src/configuration.ts
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.

	at ChildProcess.exithandler (child_process.js:206:12)
	at emitTwo (events.js:106:13)
	at ChildProcess.emit (events.js:191:7)
	at maybeClose (internal/child_process.js:877:16)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
  killed: false,
  code: 2,
  signal: null,
  cmd: 'X:\\tslint\\test\\executable\\npm-like-executable.cmd src/configuration.ts' }
	  1) exits with code 0 if correct file is passed
	  2) exits with code 0 if several files passed without `-f` flag
	  √ exits with code 1 if removed `-f` flag is passed

@ajafff
Copy link
Contributor

ajafff commented Nov 2, 2017

Actually this helps a lot. Somehow your cloned repo has the wrong line endings.
I guess you have a global git config that has core.autocrlf=true.

Try this command to clone: git clone git@github.com:palantir/tslint.git --config core.autocrlf=input --config core.eol=lf

@M0ns1gn0r
Copy link
Contributor Author

Thanks, after I fixed EOLs in configuration.ts and in formatterLoader.ts all tests passed.

Any idea why wrong EOLs lead to Warning: The 'promise-function-async' rule requires type information.?

@ajafff
Copy link
Contributor

ajafff commented Nov 3, 2017

The warnings are not relevant here. That's because the test runs tslint without --project which would be needed for promise-function-async and other rules to function correctly.

The relevant part is prefixed with ERROR:. The test expects that the repo contains no lint errors. You can make sure there are no more failures with yarn lint:from-bin. Append --fix to the command to automatically fix the remaining failures.

@ajafff ajafff closed this as completed Nov 3, 2017
@M0ns1gn0r
Copy link
Contributor Author

OK, looks like when a spawned process exits with a non-0 error code, nodejs appends its stderr to the message in the returned error. Otherwise the stderr is ignored, even if it contains something.

@M0ns1gn0r
Copy link
Contributor Author

But this raises a question: why the actual errors are not copied to the stderr?

@ajafff
Copy link
Contributor

ajafff commented Nov 3, 2017

Because TSLint outputs all failures to stdout. Changing that would break users

@quantuminformation
Copy link

I get those errors on lots of different projects, really annoying

Warning: The 'await-promise' rule requires type information.
Warning: The 'no-unused-variable' rule requires type information.
Warning: The 'no-use-before-declare' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-unnecessary-qualifier' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'strict-type-predicates' rule requires type information.

@RafaelKr
Copy link

@quantuminformation got a solution there: #1481 (comment)

@quantuminformation
Copy link

yeha got it thx

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

No branches or pull requests

4 participants