Skip to content

Commit d3d6cb5

Browse files
committed
Add tests for sample Cargo.toml files
Signed-off-by: Ritiek Malhotra <[email protected]>
1 parent d57d877 commit d3d6cb5

File tree

14 files changed

+769
-1
lines changed

14 files changed

+769
-1
lines changed

src/packagedcode/cargo.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from __future__ import print_function
2727
from __future__ import unicode_literals
2828

29+
from collections import OrderedDict
30+
2931
import io
3032
import toml
3133
import logging
@@ -93,7 +95,7 @@ def parse(location):
9395
return
9496

9597
with io.open(location, encoding='utf-8') as loc:
96-
package_data = toml.load(location)
98+
package_data = toml.load(location, _dict=OrderedDict)
9799

98100
return build_package(package_data)
99101

@@ -105,9 +107,18 @@ def build_package(package_data):
105107

106108
name = package_data.get('package').get('name')
107109
version = package_data.get('package').get('version')
110+
111+
# TODO: Remove this ordered_dict_map once cargo.py is able to handle
112+
# the appropriate data (source_packages, dependencies, etc..)
113+
# At the moment, this is only useful for making tests pass
114+
ordered_dict_map = {}
115+
for key in ("source_packages", "dependencies", "keywords", "parties"):
116+
ordered_dict_map[key] = OrderedDict()
117+
108118
package = RustCargoCrate(
109119
name=name,
110120
version=version,
121+
**ordered_dict_map
111122
)
112123

113124
return package
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[package]
2+
3+
name = "clap"
4+
version = "2.32.0"
5+
authors = ["Kevin K. <[email protected]>"]
6+
exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"]
7+
repository = "https://github.com/clap-rs/clap"
8+
documentation = "https://docs.rs/clap/"
9+
homepage = "https://clap.rs/"
10+
readme = "README.md"
11+
license = "MIT"
12+
keywords = ["argument", "cli", "arg", "parser", "parse"]
13+
categories = ["command-line-interface"]
14+
description = """
15+
A simple to use, efficient, and full featured Command Line Argument Parser
16+
"""
17+
18+
[badges]
19+
travis-ci = { repository = "clap-rs/clap" }
20+
appveyor = { repository = "clap-rs/clap" }
21+
coveralls = { repository = "clap-rs/clap", branch = "master" }
22+
is-it-maintained-issue-resolution = { repository = "clap-rs/clap" }
23+
is-it-maintained-open-issues = { repository = "clap-rs/clap" }
24+
maintenance = {status = "actively-developed"}
25+
26+
[dependencies]
27+
bitflags = "1.0"
28+
unicode-width = "0.1.4"
29+
textwrap = "0.10.0"
30+
strsim = { version = "0.8", optional = true }
31+
yaml-rust = { version = "0.3.5", optional = true }
32+
clippy = { version = "~0.0.166", optional = true }
33+
atty = { version = "0.2.2", optional = true }
34+
vec_map = { version = "0.8", optional = true }
35+
term_size = { version = "0.3.0", optional = true }
36+
37+
[target.'cfg(not(windows))'.dependencies]
38+
ansi_term = { version = "0.11", optional = true }
39+
40+
[dev-dependencies]
41+
regex = "1"
42+
# lazy_static 1.2 requires Rust 1.24.1+
43+
lazy_static = "~1.1"
44+
version-sync = "0.5"
45+
46+
[features]
47+
default = ["suggestions", "color", "vec_map"]
48+
suggestions = ["strsim"]
49+
color = ["ansi_term", "atty"]
50+
wrap_help = ["term_size", "textwrap/term_size"]
51+
yaml = ["yaml-rust"]
52+
unstable = [] # for building with unstable clap features (doesn't require nightly Rust) (currently none)
53+
nightly = [] # for building with unstable Rust features (currently none)
54+
lints = ["clippy"] # Requires nightly Rust
55+
debug = [] # Enables debug messages
56+
no_cargo = [] # Enable if you're not using Cargo, disables Cargo-env-var-dependent macros
57+
doc = ["yaml"] # All the features which add to documentation
58+
59+
[profile.release]
60+
opt-level = 3
61+
debug = false
62+
rpath = false
63+
lto = true
64+
debug-assertions = false
65+
codegen-units = 1
66+
67+
[profile.dev]
68+
opt-level = 0
69+
debug = true
70+
rpath = false
71+
lto = false
72+
debug-assertions = true
73+
codegen-units = 4
74+
75+
[profile.test]
76+
opt-level = 1
77+
debug = true
78+
rpath = false
79+
lto = false
80+
debug-assertions = true
81+
codegen-units = 4
82+
83+
[profile.bench]
84+
opt-level = 3
85+
debug = false
86+
rpath = false
87+
lto = true
88+
debug-assertions = false
89+
codegen-units = 1
90+
91+
[package.metadata.docs.rs]
92+
features = ["doc"]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"type": "cargo",
3+
"namespace": null,
4+
"name": "clap",
5+
"version": "2.32.0",
6+
"qualifiers": null,
7+
"subpath": null,
8+
"primary_language": "Rust",
9+
"description": null,
10+
"release_date": null,
11+
"parties": {},
12+
"keywords": {},
13+
"homepage_url": null,
14+
"download_url": null,
15+
"size": null,
16+
"sha1": null,
17+
"md5": null,
18+
"sha256": null,
19+
"sha512": null,
20+
"bug_tracking_url": null,
21+
"code_view_url": null,
22+
"vcs_url": null,
23+
"copyright": null,
24+
"license_expression": null,
25+
"declared_license": null,
26+
"notice_text": null,
27+
"manifest_path": null,
28+
"dependencies": {},
29+
"contains_source_code": null,
30+
"source_packages": {},
31+
"purl": "pkg:cargo/[email protected]",
32+
"repository_homepage_url": "https://crates.io//crates/clap",
33+
"repository_download_url": "https://crates.io/api/v1//crates/clap/2.32.0/download",
34+
"api_data_url": "https://crates.io/api/v1//crates/clap"
35+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[package]
2+
name = "clippy"
3+
version = "0.0.212"
4+
authors = [
5+
"Manish Goregaokar <[email protected]>",
6+
"Andre Bogus <[email protected]>",
7+
"Georg Brandl <[email protected]>",
8+
"Martin Carton <[email protected]>",
9+
"Oliver Schneider <[email protected]>"
10+
]
11+
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
12+
repository = "https://github.com/rust-lang/rust-clippy"
13+
readme = "README.md"
14+
license = "MIT/Apache-2.0"
15+
keywords = ["clippy", "lint", "plugin"]
16+
categories = ["development-tools", "development-tools::cargo-plugins"]
17+
build = "build.rs"
18+
edition = "2018"
19+
publish = false
20+
21+
[badges]
22+
travis-ci = { repository = "rust-lang/rust-clippy" }
23+
appveyor = { repository = "rust-lang/rust-clippy" }
24+
25+
[lib]
26+
name = "clippy"
27+
plugin = true
28+
test = false
29+
30+
[[bin]]
31+
name = "cargo-clippy"
32+
test = false
33+
path = "src/main.rs"
34+
35+
[[bin]]
36+
name = "clippy-driver"
37+
path = "src/driver.rs"
38+
39+
[dependencies]
40+
# begin automatic update
41+
clippy_lints = { version = "0.0.212", path = "clippy_lints" }
42+
# end automatic update
43+
regex = "1"
44+
semver = "0.9"
45+
rustc_tools_util = { version = "0.1.1", path = "rustc_tools_util"}
46+
47+
[dev-dependencies]
48+
clippy_dev = { version = "0.0.1", path = "clippy_dev" }
49+
cargo_metadata = "0.7.1"
50+
compiletest_rs = "0.3.19"
51+
lazy_static = "1.0"
52+
serde_derive = "1.0"
53+
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
54+
serde = "1.0"
55+
derive-new = "0.5"
56+
57+
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
58+
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
59+
# for more information.
60+
rustc-workspace-hack = "1.0.0"
61+
62+
[build-dependencies]
63+
rustc_tools_util = { version = "0.1.1", path = "rustc_tools_util"}
64+
65+
[features]
66+
debugging = []
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"type": "cargo",
3+
"namespace": null,
4+
"name": "clippy",
5+
"version": "0.0.212",
6+
"qualifiers": null,
7+
"subpath": null,
8+
"primary_language": "Rust",
9+
"description": null,
10+
"release_date": null,
11+
"parties": {},
12+
"keywords": {},
13+
"homepage_url": null,
14+
"download_url": null,
15+
"size": null,
16+
"sha1": null,
17+
"md5": null,
18+
"sha256": null,
19+
"sha512": null,
20+
"bug_tracking_url": null,
21+
"code_view_url": null,
22+
"vcs_url": null,
23+
"copyright": null,
24+
"license_expression": null,
25+
"declared_license": null,
26+
"notice_text": null,
27+
"manifest_path": null,
28+
"dependencies": {},
29+
"contains_source_code": null,
30+
"source_packages": {},
31+
"purl": "pkg:cargo/[email protected]",
32+
"repository_homepage_url": "https://crates.io//crates/clippy",
33+
"repository_download_url": "https://crates.io/api/v1//crates/clippy/0.0.212/download",
34+
"api_data_url": "https://crates.io/api/v1//crates/clippy"
35+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[package]
2+
name = "mdbook"
3+
version = "0.2.4-alpha.0"
4+
authors = [
5+
"Mathieu David <[email protected]>",
6+
"Michael-F-Bryan <[email protected]>",
7+
"Matt Ickstadt <[email protected]>"
8+
]
9+
description = "Create books from markdown files"
10+
documentation = "http://rust-lang-nursery.github.io/mdBook/index.html"
11+
repository = "https://github.com/rust-lang-nursery/mdBook"
12+
keywords = ["book", "gitbook", "rustbook", "markdown"]
13+
license = "MPL-2.0"
14+
readme = "README.md"
15+
exclude = ["book-example/*"]
16+
17+
[dependencies]
18+
clap = "2.24"
19+
chrono = "0.4"
20+
handlebars = "1.0"
21+
serde = "1.0"
22+
serde_derive = "1.0"
23+
error-chain = "0.12"
24+
serde_json = "1.0"
25+
pulldown-cmark = "0.1.2"
26+
lazy_static = "1.0"
27+
log = "0.4"
28+
env_logger = "0.5"
29+
toml = "0.4.8"
30+
memchr = "2.0"
31+
open = "1.1"
32+
regex = "1.0.0"
33+
tempfile = "3.0"
34+
itertools = "0.7"
35+
shlex = "0.1"
36+
toml-query = "0.7"
37+
38+
# Watch feature
39+
notify = { version = "4.0", optional = true }
40+
41+
# Serve feature
42+
iron = { version = "0.6", optional = true }
43+
staticfile = { version = "0.5", optional = true }
44+
ws = { version = "0.7", optional = true}
45+
46+
# Search feature
47+
elasticlunr-rs = { version = "2.3", optional = true, default-features = false }
48+
ammonia = { version = "1.1", optional = true }
49+
50+
[dev-dependencies]
51+
select = "0.4"
52+
pretty_assertions = "0.5"
53+
walkdir = "2.0"
54+
pulldown-cmark-to-cmark = "1.1.0"
55+
56+
[features]
57+
default = ["output", "watch", "serve", "search"]
58+
debug = []
59+
output = []
60+
watch = ["notify"]
61+
serve = ["iron", "staticfile", "ws"]
62+
search = ["elasticlunr-rs", "ammonia"]
63+
64+
[[bin]]
65+
doc = false
66+
name = "mdbook"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"type": "cargo",
3+
"namespace": null,
4+
"name": "mdbook",
5+
"version": "0.2.4-alpha.0",
6+
"qualifiers": null,
7+
"subpath": null,
8+
"primary_language": "Rust",
9+
"description": null,
10+
"release_date": null,
11+
"parties": {},
12+
"keywords": {},
13+
"homepage_url": null,
14+
"download_url": null,
15+
"size": null,
16+
"sha1": null,
17+
"md5": null,
18+
"sha256": null,
19+
"sha512": null,
20+
"bug_tracking_url": null,
21+
"code_view_url": null,
22+
"vcs_url": null,
23+
"copyright": null,
24+
"license_expression": null,
25+
"declared_license": null,
26+
"notice_text": null,
27+
"manifest_path": null,
28+
"dependencies": {},
29+
"contains_source_code": null,
30+
"source_packages": {},
31+
"purl": "pkg:cargo/[email protected]",
32+
"repository_homepage_url": "https://crates.io//crates/mdbook",
33+
"repository_download_url": "https://crates.io/api/v1//crates/mdbook/0.2.4-alpha.0/download",
34+
"api_data_url": "https://crates.io/api/v1//crates/mdbook"
35+
}

0 commit comments

Comments
 (0)