Skip to content

Commit

Permalink
#267 Add test highlighting a diskcache bug
Browse files Browse the repository at this point in the history
 * this is a Python pickle bug
 * somehow, some data structures cannot be pickled with HIGHEST_PROTOCOL
 * But they pickle alright with no proptocol set

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne committed Nov 7, 2016
1 parent 50bfc21 commit 6b92ccf
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
96 changes: 96 additions & 0 deletions tests/scancode/data/cache/package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"name": "async",
"description": "Higher-order functions and common patterns for asynchronous code",
"main": "lib/async.js",
"author": {
"name": "Caolan McMahon"
},
"version": "1.2.1",
"keywords": [
"async",
"callback",
"utility",
"module"
],
"repository": {
"type": "git",
"url": "git+https://github.com/caolan/async.git"
},
"bugs": {
"url": "https://github.com/caolan/async/issues"
},
"license": "MIT",
"devDependencies": {
"benchmark": "github:bestiejs/benchmark.js",
"coveralls": "^2.11.2",
"jshint": "~2.7.0",
"lodash": ">=2.4.1",
"mkdirp": "~0.5.1",
"nodeunit": ">0.0.0",
"nyc": "^2.1.0",
"uglify-js": "1.2.x",
"yargs": "~3.9.1"
},
"jam": {
"main": "lib/async.js",
"include": [
"lib/async.js",
"README.md",
"LICENSE"
],
"categories": [
"Utilities"
]
},
"scripts": {
"test": "npm run-script lint && nodeunit test/test-async.js",
"lint": "jshint lib/*.js test/*.js perf/*.js",
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls"
},
"spm": {
"main": "lib/async.js"
},
"volo": {
"main": "lib/async.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
},
"gitHead": "b66e85d1cca8c8056313253f22d18f571e7001d2",
"homepage": "https://github.com/caolan/async#readme",
"_id": "async@1.2.1",
"_shasum": "a4816a17cd5ff516dfa2c7698a453369b9790de0",
"_from": "async@*",
"_npmVersion": "2.9.0",
"_nodeVersion": "2.0.2",
"_npmUser": {
"name": "aearly",
"email": "alexander.early@gmail.com"
},
"maintainers": [
{
"name": "caolan",
"email": "caolan.mcmahon@gmail.com"
},
{
"name": "beaugunderson",
"email": "beau@beaugunderson.com"
},
{
"name": "aearly",
"email": "alexander.early@gmail.com"
}
],
"dist": {
"shasum": "a4816a17cd5ff516dfa2c7698a453369b9790de0",
"tarball": "http://registry.npmjs.org/async/-/async-1.2.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/async/-/async-1.2.1.tgz",
"readme": "ERROR: No README data found!"
}
45 changes: 45 additions & 0 deletions tests/scancode/test_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright (c) 2016 nexB Inc. and others. All rights reserved.
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
# The ScanCode software is licensed under the Apache License version 2.0.
# Data generated with ScanCode require an acknowledgment.
# ScanCode is a trademark of nexB Inc.
#
# You may not use this software except in compliance with the License.
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
# When you publish or redistribute any data created with ScanCode or any ScanCode
# derivative work, you must accompany this data with the following acknowledgment:
#
# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
# ScanCode should be considered or used as legal advice. Consult an Attorney
# for any legal advice.
# ScanCode is a free software code scanning tool from nexB Inc. and others.
# Visit https://github.com/nexB/scancode-toolkit/ for support and download.

from __future__ import absolute_import, print_function

import os

from commoncode.testcase import FileBasedTesting

from scancode.cache import ScanCache


class TestCache(FileBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

def test_can_cache(self):
test_file = self.get_test_loc('cache/package/package.json')
from scancode import api
package = api.get_package_infos(test_file)

test_dir = self.get_temp_dir()
cache = ScanCache(test_dir)
cache.put_infos(path='abc', file_infos=dict(sha1='def'))
cache.put_scan(path='abc', file_infos=dict(sha1='def'), scan_result=package)

0 comments on commit 6b92ccf

Please sign in to comment.