@@ -51,36 +51,65 @@ def main(argv=[], prog_name=''):
51
51
parser = argparse .ArgumentParser (prog = 'DependencyCrossmatcher' ,
52
52
description = 'Checks the version mismatches for dependencies '
53
53
'in Cargo based repositories' )
54
+ parser .add_argument ("-c" , "--compare" , action = 'store_true' ,
55
+ help = 'Check for mismatches between 2 repositories' )
54
56
parser .add_argument ('--deps_dir' ,
55
57
required = True ,
56
- help = 'Existing directory that contains the Cargo.toml for analyzing'
58
+ nargs = '+' ,
59
+ help = 'Existing directories that contain Cargo.toml for analyzing '
57
60
'dependencies' )
58
61
args = parser .parse_args ()
59
62
63
+ mismatches = dict ()
60
64
parsec_flags = '--all-features' + ' '
61
65
parsec_flags += '--features tss-esapi/generate-bindings,cryptoki/generate-bindings -d'
62
- mismatches = run_deps_mismatcher (run_cargo_tree (args .deps_dir , parsec_flags ))
63
- print_deps (mismatches )
64
66
65
- mismatches = get_deps_with_more_than_1v (mismatches )
67
+ if args .compare :
68
+ # Versions should be sorted!
69
+ exceptions = {
70
+ 'bindgen' : ['v0.66.1' ],
71
+ 'cexpr' : ['v0.6.0' ],
72
+ }
73
+ parsec_repo , parsec_tool_repo = args .deps_dir
74
+ parsec_tool_flags = '--all-features -d'
75
+ mismatches_parsec = run_deps_mismatcher (run_cargo_tree (parsec_repo , parsec_flags ))
76
+ mismatches_parsec_tool = run_deps_mismatcher (run_cargo_tree (parsec_tool_repo ,
77
+ parsec_tool_flags )
78
+ )
79
+
80
+ # Dependencies that are common to both parsec_repo and parsec_tool_repo repos
81
+ common_deps = list (set (mismatches_parsec .keys ()) & set (mismatches_parsec_tool .keys ()))
82
+ for dep in common_deps :
83
+ # Symmetric difference of repos parsec_repo and parsec_tool_repo
84
+ mistmatch = sorted (set (mismatches_parsec [dep ]) ^ set (mismatches_parsec_tool [dep ]))
85
+ if len (mistmatch ) > 0 :
86
+ mismatches [dep ] = mistmatch
87
+ else :
88
+ # Versions should be sorted!
89
+ exceptions = {
90
+ 'base64' : ['v0.13.1' , 'v0.21.4' ],
91
+ 'bindgen' : ['v0.57.0' , 'v0.66.1' ],
92
+ 'bitflags' : ['v1.3.2' , 'v2.4.1' ],
93
+ 'cexpr' : ['v0.4.0' , 'v0.6.0' ],
94
+ 'nom' : ['v5.1.3' , 'v7.1.3' ],
95
+ 'shlex' : ['v0.1.1' , 'v1.2.0' ],
96
+ 'syn' : ['v1.0.109' , 'v2.0.38' ],
97
+ }
98
+ mismatches = run_deps_mismatcher (run_cargo_tree (args .deps_dir [0 ], parsec_flags ))
99
+ mismatches = get_deps_with_more_than_1v (mismatches )
66
100
67
101
print ('---------------------exceptions-----------------------\n \n ' )
68
- exceptions = {
69
- 'base64' : ['v0.13.1' , 'v0.21.4' ],
70
- 'bindgen' : ['v0.57.0' , 'v0.66.1' ],
71
- 'bitflags' : ['v1.3.2' , 'v2.4.1' ],
72
- 'cexpr' : ['v0.4.0' , 'v0.6.0' ],
73
- 'nom' : ['v5.1.3' , 'v7.1.3' ],
74
- 'shlex' : ['v0.1.1' , 'v1.2.0' ],
75
- 'syn' : ['v1.0.109' , 'v2.0.38' ],
76
- }
77
102
print_deps (exceptions )
78
103
79
104
print ('---------------------mistmatches----------------------\n \n ' )
80
105
print_deps (mismatches )
81
106
82
- if exceptions != mismatches :
83
- return 1
107
+ if not args .compare :
108
+ errormsg = "Found dependencies version mismatches in parsec"
109
+ else :
110
+ errormsg = "Found dependencies version mismatches between parsec and parsec-tool"
111
+
112
+ assert exceptions == mismatches , errormsg
84
113
85
114
return 0
86
115
0 commit comments