testdata_rt/
lib.rs

1//! Runtime definitions for the `testdata` crate.
2
3#![cfg_attr(all(feature = "__doc_cfg", doc), feature(doc_cfg))]
4
5mod fixtures;
6mod formats;
7mod globbing;
8mod patterns;
9mod snapshots;
10mod test_input;
11
12use std::io;
13use std::path::Path;
14
15pub use crate::fixtures::{pending, TestFile};
16#[cfg(any(feature = "serde_json", all(feature = "__doc_cfg", doc)))]
17pub use crate::formats::json::Json;
18pub use crate::globbing::{ArgSpec, GlobError, GlobSpec};
19pub use crate::patterns::{GlobParseError, GlobPattern};
20pub use crate::snapshots::{assert_snapshot_helper, Snapshot, SnapshotMode};
21pub use crate::test_input::TestInput;
22#[doc(hidden)]
23pub extern crate pretty_assertions;
24
25/// An equivalent to the `touch` command.
26pub fn touch(path: &Path) -> io::Result<()> {
27    // Touch the file containing the test
28    let now = std::time::SystemTime::now()
29        .duration_since(std::time::UNIX_EPOCH)
30        .map(|d| d.as_secs())
31        .unwrap_or(0);
32    utime::set_file_times(path, now as i64, now as i64)?;
33    Ok(())
34}