@@ -385,6 +385,8 @@ pub struct ElpConfig {
385385 pub eqwalizer : EqwalizerConfig ,
386386 #[ serde( default ) ]
387387 pub rebar : ElpRebarConfig ,
388+ #[ serde( default ) ]
389+ pub otp : OtpConfig ,
388390}
389391
390392#[ derive(
@@ -501,6 +503,22 @@ impl Default for ElpRebarConfig {
501503 }
502504}
503505
506+ #[ derive(
507+ Debug ,
508+ Default ,
509+ Clone ,
510+ PartialEq ,
511+ Eq ,
512+ Hash ,
513+ Ord ,
514+ PartialOrd ,
515+ Deserialize ,
516+ Serialize
517+ ) ]
518+ pub struct OtpConfig {
519+ pub exclude_apps : Vec < String > ,
520+ }
521+
504522impl ElpConfig {
505523 pub fn new (
506524 config_path : AbsPathBuf ,
@@ -515,6 +533,7 @@ impl ElpConfig {
515533 build_info,
516534 eqwalizer,
517535 rebar,
536+ otp : OtpConfig :: default ( ) ,
518537 }
519538 }
520539 pub fn try_parse ( path : & AbsPath ) -> Result < ElpConfig > {
@@ -998,7 +1017,7 @@ impl Project {
9981017
9991018 pub fn load (
10001019 manifest : & ProjectManifest ,
1001- eqwalizer_config : EqwalizerConfig ,
1020+ elp_config : & ElpConfig ,
10021021 query_config : & BuckQueryConfig ,
10031022 report_progress : & impl Fn ( & str ) ,
10041023 ) -> Result < Project > {
@@ -1032,7 +1051,7 @@ impl Project {
10321051 ProjectManifest :: TomlBuck ( buck) => {
10331052 // We only select this manifest if buck is actually enabled
10341053 let ( project, apps, otp_root, include_mapping) =
1035- BuckProject :: load_from_config ( buck, query_config, report_progress) ?;
1054+ BuckProject :: load_from_config ( buck, elp_config , query_config, report_progress) ?;
10361055 (
10371056 ProjectBuildData :: Buck ( project) ,
10381057 apps,
@@ -1061,14 +1080,14 @@ impl Project {
10611080 }
10621081 } ;
10631082
1064- let ( otp, otp_project_apps) = Otp :: discover ( otp_root) ;
1083+ let ( otp, otp_project_apps) = Otp :: discover ( otp_root, & elp_config . otp ) ;
10651084 project_apps. extend ( otp_project_apps) ;
10661085 report_progress ( "Project info loaded" ) ;
10671086 Ok ( Project {
10681087 otp,
10691088 project_build_data : project_build_info,
10701089 project_apps,
1071- eqwalizer_config,
1090+ eqwalizer_config : elp_config . eqwalizer . clone ( ) ,
10721091 include_mapping,
10731092 } )
10741093 }
@@ -1172,6 +1191,9 @@ mod tests {
11721191 rebar: ElpRebarConfig {
11731192 profile: "test",
11741193 },
1194+ otp: OtpConfig {
1195+ exclude_apps: [],
1196+ },
11751197 },
11761198 Rebar(
11771199 RebarConfig {
@@ -1237,6 +1259,9 @@ mod tests {
12371259 rebar: ElpRebarConfig {
12381260 profile: "test",
12391261 },
1262+ otp: OtpConfig {
1263+ exclude_apps: [],
1264+ },
12401265 },
12411266 Json(
12421267 JsonConfig {
@@ -1347,6 +1372,9 @@ mod tests {
13471372 rebar: ElpRebarConfig {
13481373 profile: "test",
13491374 },
1375+ otp: OtpConfig {
1376+ exclude_apps: [],
1377+ },
13501378 },
13511379 JsonConfig {
13521380 apps: [
@@ -1502,6 +1530,9 @@ mod tests {
15021530 rebar: ElpRebarConfig {
15031531 profile: "test",
15041532 },
1533+ otp: OtpConfig {
1534+ exclude_apps: [],
1535+ },
15051536 },
15061537 NoManifest(
15071538 NoManifestConfig {
@@ -1571,6 +1602,9 @@ mod tests {
15711602 rebar: ElpRebarConfig {
15721603 profile: "test",
15731604 },
1605+ otp: OtpConfig {
1606+ exclude_apps: [],
1607+ },
15741608 },
15751609 NoManifest(
15761610 NoManifestConfig {
@@ -1764,6 +1798,9 @@ mod tests {
17641798 rebar: ElpRebarConfig {
17651799 profile: "other",
17661800 },
1801+ otp: OtpConfig {
1802+ exclude_apps: [],
1803+ },
17671804 }
17681805 "# ] ]
17691806 . assert_eq ( & debug_normalise_temp_dir ( dir, & elp_config) ) ;
@@ -1807,6 +1844,7 @@ mod tests {
18071844 rebar : ElpRebarConfig {
18081845 profile : "my_profile" . to_string ( ) ,
18091846 } ,
1847+ otp : OtpConfig :: default ( ) ,
18101848 } )
18111849 . unwrap ( ) ;
18121850 expect ! [ [ r#"
@@ -1829,6 +1867,9 @@ mod tests {
18291867
18301868 [rebar]
18311869 profile = "my_profile"
1870+
1871+ [otp]
1872+ exclude_apps = []
18321873 "# ] ]
18331874 . assert_eq ( & result) ;
18341875 }
@@ -1902,6 +1943,9 @@ mod tests {
19021943 rebar: ElpRebarConfig {
19031944 profile: "my_profile",
19041945 },
1946+ otp: OtpConfig {
1947+ exclude_apps: [],
1948+ },
19051949 }
19061950 "# ] ]
19071951 . assert_debug_eq ( & lints) ;
@@ -2017,4 +2061,112 @@ mod tests {
20172061 }
20182062 }
20192063 }
2064+
2065+ #[ test]
2066+ fn test_toml_otp_exclude_apps ( ) {
2067+ let spec = r#"
2068+ //- /.elp.toml
2069+ [otp]
2070+ exclude_apps = ["megaco", "eunit"]
2071+ //- /app_a/src/app.erl
2072+ -module(app).
2073+ "# ;
2074+ let dir = FixtureWithProjectMeta :: gen_project ( spec) ;
2075+ if let Ok ( ( elp_config, ProjectManifest :: NoManifest ( _) ) ) = ProjectManifest :: discover (
2076+ & to_abs_path_buf ( & dir. path ( ) . join ( "app_a/src/app.erl" ) ) . unwrap ( ) ,
2077+ ) {
2078+ expect ! [ [ r#"
2079+ ElpConfig {
2080+ config_path: Some(
2081+ AbsPathBuf(
2082+ "TMPDIR/.elp.toml",
2083+ ),
2084+ ),
2085+ build_info: None,
2086+ buck: None,
2087+ eqwalizer: EqwalizerConfig {
2088+ enable_all: true,
2089+ max_tasks: 4,
2090+ ignore_modules: [],
2091+ ignore_modules_compiled_patterns: [],
2092+ },
2093+ rebar: ElpRebarConfig {
2094+ profile: "test",
2095+ },
2096+ otp: OtpConfig {
2097+ exclude_apps: [
2098+ "megaco",
2099+ "eunit",
2100+ ],
2101+ },
2102+ }
2103+ "# ] ]
2104+ . assert_eq ( & debug_normalise_temp_dir ( dir, & elp_config) ) ;
2105+ } else {
2106+ panic ! ( )
2107+ }
2108+ }
2109+
2110+ #[ test]
2111+ fn serde_serialize_elp_toml_with_otp ( ) {
2112+ let result = toml:: to_string :: < ElpConfig > ( & ElpConfig {
2113+ config_path : None ,
2114+ build_info : None ,
2115+ buck : None ,
2116+ eqwalizer : EqwalizerConfig :: default ( ) ,
2117+ rebar : ElpRebarConfig :: default ( ) ,
2118+ otp : OtpConfig {
2119+ exclude_apps : vec ! [ "megaco" . to_string( ) , "eunit" . to_string( ) ] ,
2120+ } ,
2121+ } )
2122+ . unwrap ( ) ;
2123+ expect ! [ [ r#"
2124+ [eqwalizer]
2125+ enable_all = true
2126+ max_tasks = 4
2127+ ignore_modules = []
2128+
2129+ [rebar]
2130+ profile = "test"
2131+
2132+ [otp]
2133+ exclude_apps = ["megaco", "eunit"]
2134+ "# ] ]
2135+ . assert_eq ( & result) ;
2136+ }
2137+
2138+ #[ test]
2139+ fn serde_deserialize_elp_toml_with_otp ( ) {
2140+ let config: ElpConfig = toml:: from_str (
2141+ r#"
2142+ [otp]
2143+ exclude_apps = ["megaco", "eunit"]
2144+ "# ,
2145+ )
2146+ . unwrap ( ) ;
2147+
2148+ expect ! [ [ r#"
2149+ ElpConfig {
2150+ config_path: None,
2151+ build_info: None,
2152+ buck: None,
2153+ eqwalizer: EqwalizerConfig {
2154+ enable_all: true,
2155+ max_tasks: 4,
2156+ ignore_modules: [],
2157+ ignore_modules_compiled_patterns: [],
2158+ },
2159+ rebar: ElpRebarConfig {
2160+ profile: "test",
2161+ },
2162+ otp: OtpConfig {
2163+ exclude_apps: [
2164+ "megaco",
2165+ "eunit",
2166+ ],
2167+ },
2168+ }
2169+ "# ] ]
2170+ . assert_debug_eq ( & config) ;
2171+ }
20202172}
0 commit comments