fix(tests): collision-proof parser test temp files to deflake macOS CI
This commit is contained in:
2 files changed
+11
-8
No files matched your search
@@ -367,9 +367,11 @@ mod tests {
|
|||||||
file_name: &str,
|
file_name: &str,
|
||||||
parent: &Path,
|
parent: &Path,
|
||||||
) -> Result<Vec<FunctionDeclaration>> {
|
) -> Result<Vec<FunctionDeclaration>> {
|
||||||
|
let pid = std::process::id();
|
||||||
let unique = PARSE_COUNTER.fetch_add(1, Ordering::Relaxed);
|
let unique = PARSE_COUNTER.fetch_add(1, Ordering::Relaxed);
|
||||||
let path =
|
let path = std::env::temp_dir().join(format!(
|
||||||
std::env::temp_dir().join(format!("coyote_python_parser_{file_name}_{unique}.py"));
|
"coyote_python_parser_{file_name}_{pid}_{unique}.py"
|
||||||
|
));
|
||||||
fs::write(&path, source).expect("failed to write temp python source");
|
fs::write(&path, source).expect("failed to write temp python source");
|
||||||
let file = File::open(&path).expect("failed to open temp python source");
|
let file = File::open(&path).expect("failed to open temp python source");
|
||||||
let result = generate_python_declarations(file, file_name, Some(parent));
|
let result = generate_python_declarations(file, file_name, Some(parent));
|
||||||
|
|||||||
@@ -414,18 +414,19 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::function::JsonSchema;
|
use crate::function::JsonSchema;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
|
|
||||||
|
static PARSE_COUNTER: AtomicU64 = AtomicU64::new(0);
|
||||||
|
|
||||||
fn parse_ts_source(
|
fn parse_ts_source(
|
||||||
source: &str,
|
source: &str,
|
||||||
file_name: &str,
|
file_name: &str,
|
||||||
parent: &Path,
|
parent: &Path,
|
||||||
) -> Result<Vec<FunctionDeclaration>> {
|
) -> Result<Vec<FunctionDeclaration>> {
|
||||||
let unique = SystemTime::now()
|
let pid = std::process::id();
|
||||||
.duration_since(UNIX_EPOCH)
|
let unique = PARSE_COUNTER.fetch_add(1, Ordering::Relaxed);
|
||||||
.expect("time")
|
let path =
|
||||||
.as_nanos();
|
std::env::temp_dir().join(format!("coyote_ts_parser_{file_name}_{pid}_{unique}.ts"));
|
||||||
let path = std::env::temp_dir().join(format!("coyote_ts_parser_{file_name}_{unique}.ts"));
|
|
||||||
fs::write(&path, source).expect("write");
|
fs::write(&path, source).expect("write");
|
||||||
let file = File::open(&path).expect("open");
|
let file = File::open(&path).expect("open");
|
||||||
let result = generate_typescript_declarations(file, file_name, Some(parent));
|
let result = generate_typescript_declarations(file, file_name, Some(parent));
|
||||||
|
|||||||
Reference in new issue
Block a user