{"action":"created","issue":{"url":"https://api.github.com/repos/benderjs/benderjs/issues/156","labels_url":"https://api.github.com/repos/benderjs/benderjs/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/benderjs/benderjs/issues/156/comments","events_url":"https://api.github.com/repos/benderjs/benderjs/issues/156/events","html_url":"https://github.com/benderjs/benderjs/issues/156","id":54449910,"number":156,"title":"Test paths and getting rid of the basePath","user":{"login":"gregpabian","id":6839055,"avatar_url":"https://avatars.githubusercontent.com/u/6839055?v=3","gravatar_id":"","url":"https://api.github.com/users/gregpabian","html_url":"https://github.com/gregpabian","followers_url":"https://api.github.com/users/gregpabian/followers","following_url":"https://api.github.com/users/gregpabian/following{/other_user}","gists_url":"https://api.github.com/users/gregpabian/gists{/gist_id}","starred_url":"https://api.github.com/users/gregpabian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregpabian/subscriptions","organizations_url":"https://api.github.com/users/gregpabian/orgs","repos_url":"https://api.github.com/users/gregpabian/repos","events_url":"https://api.github.com/users/gregpabian/events{/privacy}","received_events_url":"https://api.github.com/users/gregpabian/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/benderjs/benderjs/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/benderjs/benderjs/milestones/13","labels_url":"https://api.github.com/repos/benderjs/benderjs/milestones/13/labels","id":908307,"number":13,"title":"0.2.0","description":"","creator":{"login":"gregpabian","id":6839055,"avatar_url":"https://avatars.githubusercontent.com/u/6839055?v=3","gravatar_id":"","url":"https://api.github.com/users/gregpabian","html_url":"https://github.com/gregpabian","followers_url":"https://api.github.com/users/gregpabian/followers","following_url":"https://api.github.com/users/gregpabian/following{/other_user}","gists_url":"https://api.github.com/users/gregpabian/gists{/gist_id}","starred_url":"https://api.github.com/users/gregpabian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregpabian/subscriptions","organizations_url":"https://api.github.com/users/gregpabian/orgs","repos_url":"https://api.github.com/users/gregpabian/repos","events_url":"https://api.github.com/users/gregpabian/events{/privacy}","received_events_url":"https://api.github.com/users/gregpabian/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":0,"state":"open","created_at":"2014-12-18T14:09:40Z","updated_at":"2015-01-19T08:04:12Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-01-15T13:39:25Z","updated_at":"2015-01-19T10:09:52Z","closed_at":null,"body":"For the last couple of days I've been refactoring the piece of code responsible for finding and listing all the tests defined in the configuration file. This ended up releasing a new version of [benderjs/gerard](https://github.com/benderjs/gerard) and introduced the idea of getting rid of the basePath parameter.\r\n\r\nTo illustrate this better, here's how we defined a test group before:\r\n```js\r\n...\r\ntests: {\r\n    'Plugins': {\r\n        applications: [ 'ckeditor' ],\r\n        basePath: 'tests/',\r\n        paths: [\r\n            'plugins/**',\r\n            '!**/_*/**'\r\n    ],\r\n    'External Plugins': {\r\n        applications: [ 'ckeditor' ],\r\n        basePath: 'plugins/',\r\n        paths: [\r\n            '*/tests/**',\r\n            '!**/_*/**'\r\n        ]\r\n    },\r\n    ...\r\n}\r\n...\r\n```\r\n\r\nNow we can do the following:\r\n```js\r\n...\r\ntests: {\r\n    'Plugins': {\r\n        applications: [ 'ckeditor' ],\r\n        paths: [\r\n            'tests/plugins/**',\r\n            'plugins/*/tests/**',\r\n            '!**/_*/**'\r\n        ],\r\n    }\r\n    ...\r\n}\r\n...\r\n```\r\n\r\nHere's a list of pros and cons of the following solution:\r\n\r\nPros:\r\n\r\n- Shorter and less confusing test group definitions\r\n- Works waaaay faster than the old version (about 3 times faster on the first tests.list() call, and at least 5 times faster on second and later calls)\r\n\r\nCons:\r\n\r\n1. Taking a snapshot of a test group for a job is a pain in the *** right now\r\n2. It's hard to tell what `%BASE_PATH%` should return\r\n3. Accessing assets will be broken\r\n4. Relative paths will eventually break some things\r\n\r\nAd. 1.\r\nIt's hard to tell what directory/files should be copied since we can use following paths:\r\n\r\n  - `tests/plugins/**/*.js`\r\n  - `plugin-*/tests/**`\r\n\r\nWe could copy files matching the pattern only, but what about assets?\r\n\r\nOne of the solutions is to treat every first bit of a path as a basePath (or a basePath pattern) and usem them to take a snapshot. So for the above paths it would copy:\r\n\r\n- entire `tests/` directory\r\n- every directory that matches `plugin-*`\r\n\r\nAd. 3.\r\nFor the sake of security we permit accessing files within selected directories (e.g. tests and application resources) or even the selected files only (e.g. plugin resources), in previous implementation these paths included basePaths, but I'm not sure what should we use now.\r\n\r\nAd. 4.\r\nAs we assumed at the beginning of the project, test URLs should reflect the actual test folder structure in the file system. Now, even though the relative tests path will work and Bender will list the tests inside of them properly, the produced test URLs will be broken..."},"comment":{"url":"https://api.github.com/repos/benderjs/benderjs/issues/comments/70470677","html_url":"https://github.com/benderjs/benderjs/issues/156#issuecomment-70470677","issue_url":"https://api.github.com/repos/benderjs/benderjs/issues/156","id":70470677,"user":{"login":"Reinmar","id":156149,"avatar_url":"https://avatars.githubusercontent.com/u/156149?v=3","gravatar_id":"","url":"https://api.github.com/users/Reinmar","html_url":"https://github.com/Reinmar","followers_url":"https://api.github.com/users/Reinmar/followers","following_url":"https://api.github.com/users/Reinmar/following{/other_user}","gists_url":"https://api.github.com/users/Reinmar/gists{/gist_id}","starred_url":"https://api.github.com/users/Reinmar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Reinmar/subscriptions","organizations_url":"https://api.github.com/users/Reinmar/orgs","repos_url":"https://api.github.com/users/Reinmar/repos","events_url":"https://api.github.com/users/Reinmar/events{/privacy}","received_events_url":"https://api.github.com/users/Reinmar/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T10:09:52Z","updated_at":"2015-01-19T10:09:52Z","body":"> Not really - ignored list is used exclude some files from being recognized as a test.\r\n\r\nI meant a totally new setting - a setting for the general file lookup. If a file matches any ignored files pattern it's not consider by Bender as anything that can be served, become a snapshot, or a test file.\r\n\r\n> For security reasons, I'd rather assume that everything gets 404 unless it matches a test group's path. \r\n\r\nSo we can talk about \"findable\" files instead of \"ignored\" files. This will be explicit - you need to configure which files in the root directory Bender will notice at all.\r\n\r\n> Now, the problematic piece is the basePath parameter which defaults to '.' and you can imagine what might happen if we try to take a snapshot of that ;)\r\n\r\nIf we take the above I don't think it will be a problem."}}