-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pytest: fix nayduck looking for contracts that are long long gone
Storing build artifacts in the source directory shouldn't be happening. Although not an ideal, this is introducing a near-test-contracts binary that can output the contracts upon request. A good solution would be for pytest to either maintain their own contracts or link to `near-test-contracts` proper and grab the contracts by calling a function, just like is done in the rest of the test suite.
- Loading branch information
Showing
2 changed files
with
36 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::io::Write as _; | ||
|
||
use near_test_contracts::*; | ||
|
||
fn main() { | ||
let contract_name = std::env::args() | ||
.nth(1) | ||
.expect("expecting one argument with the name of the contract to return"); | ||
let Some((name, extension)) = contract_name.rsplit_once(".") else { | ||
panic!("argument expected in `filename.ext` form"); | ||
}; | ||
let code = match &*name { | ||
"trivial" => trivial_contract(), | ||
"rs_contract" => rs_contract(), | ||
"backwards_compatible_rs_contract" => backwards_compatible_rs_contract(), | ||
"nightly_rs_contract" => nightly_rs_contract(), | ||
"ts_contract" => ts_contract(), | ||
"fuzzing_contract" => fuzzing_contract(), | ||
"ft_contract" => ft_contract(), | ||
"smallest_rs_contract" => smallest_rs_contract(), | ||
"estimator_contract" => estimator_contract(), | ||
"congestion_control_test_contract" => congestion_control_test_contract(), | ||
_ => panic!("unknown contract {name}"), | ||
}; | ||
if extension == "wasm" { | ||
std::io::stdout().write_all(&code).expect("while writing code to stdout"); | ||
} else { | ||
panic!("unsupported filetype `{extension}`"); | ||
} | ||
} |