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

Update paths to run on windows #23674

Closed
wants to merge 2 commits into from

Conversation

liza-mae
Copy link
Contributor

@liza-mae liza-mae commented Oct 2, 2018

Replace backslash with forward slash for windows, to fix unit test failures with getRelativePath(), getRelativeParentDirs() and getInstalledPackages()

Failures:

  1. dev/File #getRelativePath() returns the path relative to the repo root:
      Error: expected 'src\\dev\\__tests__\\file.js' to sort of equal 'src/dev/__tests__/file.js'
      + expected - actual

      -src\dev\__tests__\file.js
      +src/dev/__tests__/file.js
      
      at Assertion.assert (node_modules\expect.js\index.js:96:13)
      at Assertion.eql (node_modules\expect.js\index.js:230:10)
      at Context.it (C:/Users/vagrant/kibana/src/dev/__tests__/file.js:41:41)
  1. dev/File #getRelativeParentDirs() returns the parents of a file, stopping at the repo root, in descending order:
      Error: expected [ 'src\\dev\\__tests__', 'src\\dev', 'src' ] to sort of equal [ 'src/dev/__tests__', 'src/dev', 'src' ]
      + expected - actual

       [
      -  "src\\dev\\__tests__"
      -  "src\\dev"
      +  "src/dev/__tests__"
      +  "src/dev"
         "src"
       ]
      
      at Assertion.assert (node_modules\expect.js\index.js:96:13)
      at Assertion.eql (node_modules\expect.js\index.js:230:10)
      at Context.it (C:/Users/vagrant/kibana/src/dev/__tests__/file.js:71:47)
  1. src/dev/npm/installed_packages getInstalledPackages() reads all installed packages of a module:
 Error: expected [ { name: 'dep1',
    version: '0.0.2',
    repository: 'https://github.com/mycorp/dep1',
    licenses: [ 'Apache-2.0' ],
    directory: 'C:\\Users\\vagrant\\kibana\\src\\dev\\npm\\__tests__\\fixtures\\fixture1\\node_modules\\dep1',
    relative: 'node_modules\\dep1' },
  { name: 'privatedep',
    version: '0.0.2',
    repository: 'https://github.com/mycorp/privatedep',
    licenses: [ 'Apache-2.0' ],
    directory: 'C:\\Users\\vagrant\\kibana\\src\\dev\\npm\\__tests__\\fixtures\\fixture1\\node_modules\\privatedep',
    relative: 'node_modules\\privatedep' } ] to sort of equal [ { name: 'dep1',
    version: '0.0.2',
    licenses: [ 'Apache-2.0' ],
    repository: 'https://github.com/mycorp/dep1',
    directory: 'C:\\Users\\vagrant\\kibana\\src\\dev\\npm\\__tests__\\fixtures\\fixture1\\node_modules\\dep1',
    relative: 'node_modules/dep1' },
  { name: 'privatedep',
    version: '0.0.2',
    repository: 'https://github.com/mycorp/privatedep',
    licenses: [ 'Apache-2.0' ],
    directory: 'C:\\Users\\vagrant\\kibana\\src\\dev\\npm\\__tests__\\fixtures\\fixture1\\node_modules\\privatedep',
    relative: 'node_modules/privatedep' } ]
      + expected - actual

           "licenses": [
             "Apache-2.0"
           ]
           "name": "dep1"
      -    "relative": "node_modules\\dep1"
      +    "relative": "node_modules/dep1"
           "repository": "https://github.com/mycorp/dep1"
           "version": "0.0.2"
         }
         {
           "licenses": [
             "Apache-2.0"
           ]
           "name": "privatedep"
      -    "relative": "node_modules\\privatedep"
      +    "relative": "node_modules/privatedep"
           "repository": "https://github.com/mycorp/privatedep"
           "version": "0.0.2"
         }
       ]
      
      at Assertion.assert (node_modules\expect.js\index.js:96:13)
      at Assertion.eql (node_modules\expect.js\index.js:230:10)
      at Context.it (C:/Users/vagrant/kibana/src/dev/npm/__tests__/installed_packages.js:57:35)

Part of issue: #21315

@liza-mae liza-mae self-assigned this Oct 2, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@liza-mae
Copy link
Contributor Author

liza-mae commented Oct 2, 2018

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@liza-mae liza-mae requested a review from tylersmalley October 2, 2018 18:14
Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

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

Apologies for the delay, I was on holiday the week prior to EAH.

I don't believe the issue is in the implementation here, but rather the tests which are explicitly testing a unix path. When running on Windows the path module will assume Windows-style paths, otherwise, it will use POSIX. You can force a specific interpreter to be used through path.{posix,win32}. Can we instead update the tests to use path.posix.resolve()?

@liza-mae
Copy link
Contributor Author

@tylersmalley I am not sure I understand the change, can you point it to me in the code where you want this done?

@liza-mae
Copy link
Contributor Author

Closing per #24281

@liza-mae liza-mae closed this Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants