Skip to content

Commit 2f80366

Browse files
committed
Move preproc tests
1 parent 15ec56f commit 2f80366

File tree

3 files changed

+34
-42
lines changed

3 files changed

+34
-42
lines changed

crates/compilers/src/preprocessor/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ use solar_parse::{
2222
},
2323
Parser,
2424
};
25-
use solar_sema::ParsingContext;
25+
use solar_sema::{thread_local::ThreadLocal, ParsingContext};
2626
use std::{
2727
collections::HashSet,
2828
path::{Path, PathBuf},
2929
};
30-
use solar_sema::thread_local::ThreadLocal;
3130

3231
mod data;
3332
mod deps;

crates/compilers/tests/preprocessor.rs

Lines changed: 0 additions & 40 deletions
This file was deleted.

crates/compilers/tests/project.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use foundry_compilers::{
1515
flatten::Flattener,
1616
info::ContractInfo,
1717
multi::MultiCompilerRestrictions,
18+
preprocessor::TestOptimizerPreprocessor,
19+
project::ProjectCompiler,
1820
project_util::*,
1921
solc::{Restriction, SolcRestrictions, SolcSettings},
2022
take_solc_installer_lock, Artifact, ConfigurableArtifacts, ExtraOutputValues, Graph, Project,
@@ -34,6 +36,7 @@ use semver::Version;
3436
use similar_asserts::assert_eq;
3537
use std::{
3638
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
39+
env,
3740
fs::{self},
3841
io,
3942
path::{Path, PathBuf, MAIN_SEPARATOR},
@@ -4154,3 +4157,33 @@ contract A { }
41544157
);
41554158
});
41564159
}
4160+
4161+
#[test]
4162+
fn can_preprocess_constructors_and_creation_code() {
4163+
let root =
4164+
canonicalize(Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/preprocessor"))
4165+
.unwrap();
4166+
4167+
let paths = ProjectPathsConfig::builder()
4168+
.sources(root.join("src"))
4169+
.tests(root.join("test"))
4170+
.root(&root)
4171+
.build::<SolcLanguage>()
4172+
.unwrap();
4173+
4174+
let project = ProjectBuilder::<SolcCompiler>::new(Default::default())
4175+
.paths(paths)
4176+
.build(SolcCompiler::default())
4177+
.unwrap();
4178+
4179+
// TODO: figure out how to set root to parsing context.
4180+
let cur_dir = env::current_dir().unwrap();
4181+
env::set_current_dir(root).unwrap();
4182+
let compiled = ProjectCompiler::new(&project)
4183+
.unwrap()
4184+
.with_preprocessor(TestOptimizerPreprocessor)
4185+
.compile()
4186+
.expect("failed to compile");
4187+
compiled.assert_success();
4188+
env::set_current_dir(cur_dir).unwrap();
4189+
}

0 commit comments

Comments
 (0)