Skip to content

Commit aba8cba

Browse files
committed
Disable tests that assume working copy is using git
These tests should be changed to not require the working copy is using git, but create their own temporary git repository instead. Signed-off-by: J Robert Ray <[email protected]>
1 parent 3a5825b commit aba8cba

File tree

2 files changed

+89
-89
lines changed

2 files changed

+89
-89
lines changed

crates/spk-build/src/build/sources_test.rs

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -45,71 +45,71 @@ fn test_validate_sources_changeset_ok() {
4545
assert!(res.is_ok());
4646
}
4747

48-
#[rstest]
49-
#[tokio::test]
50-
async fn test_sources_subdir(_tmpdir: tempfile::TempDir) {
51-
let rt = spfs_runtime().await;
52-
53-
let tar_file = rt.tmpdir.path().join("archive.tar.gz");
54-
let writer = std::fs::OpenOptions::new()
55-
.write(true)
56-
.create(true)
57-
.truncate(true)
58-
.open(&tar_file)
59-
.unwrap();
60-
let mut builder = tar::Builder::new(writer);
61-
builder.append_path("src/lib.rs").unwrap();
62-
builder.finish().unwrap();
63-
64-
let tar_source = TarSource {
65-
tar: tar_file.to_string_lossy().to_string(),
66-
// purposefully add leading slash to make sure it doesn't fail
67-
subdir: Some("/archive/src".to_string()),
68-
};
69-
let git_source = GitSource {
70-
git: std::env::current_dir()
71-
.unwrap()
72-
// Now that we're in a sub-crate, to find the root of the git
73-
// project we need to pop two directories.
74-
.parent()
75-
.unwrap()
76-
.parent()
77-
.unwrap()
78-
.to_string_lossy()
79-
.to_string(),
80-
subdir: Some("git_repo".to_string()),
81-
depth: 1,
82-
reference: String::new(),
83-
};
84-
let source_dir = rt.tmpdir.path().join("source");
85-
source_dir.join("file.txt").ensure();
86-
source_dir.join(".git/gitfile").ensure();
87-
let dir_source = LocalSource::new(source_dir).set_subdir("local");
88-
let source_file = rt.tmpdir.path().join("src").join("source_file.txt");
89-
source_file.ensure();
90-
let file_source = LocalSource::new(source_file).set_subdir("local");
91-
92-
let dest_dir = rt.tmpdir.path().join("dest");
93-
let mut spec = v0::Spec::new("test-pkg/1.0.0/src".parse().unwrap());
94-
spec.sources = vec![
95-
SourceSpec::Git(git_source),
96-
SourceSpec::Tar(tar_source),
97-
SourceSpec::Local(file_source),
98-
SourceSpec::Local(dir_source),
99-
];
100-
collect_sources(&Spec::from(spec), &dest_dir).unwrap();
101-
assert!(dest_dir.join("local").is_dir());
102-
assert!(dest_dir.join("git_repo").is_dir());
103-
assert!(dest_dir.join("archive/src").is_dir());
104-
assert!(dest_dir.join("archive/src/src/lib.rs").is_file());
105-
assert!(dest_dir.join("git_repo/crates/spk/src/cli.rs").is_file());
106-
assert!(
107-
!dest_dir.join("local/.git").exists(),
108-
"should exclude git repo"
109-
);
110-
assert!(dest_dir.join("local/file.txt").is_file());
111-
assert!(dest_dir.join("local/source_file.txt").is_file());
112-
}
48+
// #[rstest]
49+
// #[tokio::test]
50+
// async fn test_sources_subdir(_tmpdir: tempfile::TempDir) {
51+
// let rt = spfs_runtime().await;
52+
//
53+
// let tar_file = rt.tmpdir.path().join("archive.tar.gz");
54+
// let writer = std::fs::OpenOptions::new()
55+
// .write(true)
56+
// .create(true)
57+
// .truncate(true)
58+
// .open(&tar_file)
59+
// .unwrap();
60+
// let mut builder = tar::Builder::new(writer);
61+
// builder.append_path("src/lib.rs").unwrap();
62+
// builder.finish().unwrap();
63+
//
64+
// let tar_source = TarSource {
65+
// tar: tar_file.to_string_lossy().to_string(),
66+
// // purposefully add leading slash to make sure it doesn't fail
67+
// subdir: Some("/archive/src".to_string()),
68+
// };
69+
// let git_source = GitSource {
70+
// git: std::env::current_dir()
71+
// .unwrap()
72+
// // Now that we're in a sub-crate, to find the root of the git
73+
// // project we need to pop two directories.
74+
// .parent()
75+
// .unwrap()
76+
// .parent()
77+
// .unwrap()
78+
// .to_string_lossy()
79+
// .to_string(),
80+
// subdir: Some("git_repo".to_string()),
81+
// depth: 1,
82+
// reference: String::new(),
83+
// };
84+
// let source_dir = rt.tmpdir.path().join("source");
85+
// source_dir.join("file.txt").ensure();
86+
// source_dir.join(".git/gitfile").ensure();
87+
// let dir_source = LocalSource::new(source_dir).set_subdir("local");
88+
// let source_file = rt.tmpdir.path().join("src").join("source_file.txt");
89+
// source_file.ensure();
90+
// let file_source = LocalSource::new(source_file).set_subdir("local");
91+
//
92+
// let dest_dir = rt.tmpdir.path().join("dest");
93+
// let mut spec = v0::Spec::new("test-pkg/1.0.0/src".parse().unwrap());
94+
// spec.sources = vec![
95+
// SourceSpec::Git(git_source),
96+
// SourceSpec::Tar(tar_source),
97+
// SourceSpec::Local(file_source),
98+
// SourceSpec::Local(dir_source),
99+
// ];
100+
// collect_sources(&Spec::from(spec), &dest_dir).unwrap();
101+
// assert!(dest_dir.join("local").is_dir());
102+
// assert!(dest_dir.join("git_repo").is_dir());
103+
// assert!(dest_dir.join("archive/src").is_dir());
104+
// assert!(dest_dir.join("archive/src/src/lib.rs").is_file());
105+
// assert!(dest_dir.join("git_repo/crates/spk/src/cli.rs").is_file());
106+
// assert!(
107+
// !dest_dir.join("local/.git").exists(),
108+
// "should exclude git repo"
109+
// );
110+
// assert!(dest_dir.join("local/file.txt").is_file());
111+
// assert!(dest_dir.join("local/source_file.txt").is_file());
112+
// }
113113

114114
#[rstest]
115115
#[tokio::test]

crates/spk-schema/src/source_spec_test.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,30 @@ fn test_local_source_file(tmpdir: tempfile::TempDir) {
4141
assert!(dest_dir.join("file.txt").exists());
4242
}
4343

44-
#[rstest]
45-
fn test_git_sources(tmpdir: tempfile::TempDir) {
46-
init_logging();
47-
let source_dir = tmpdir.path().join("source");
48-
let dest_dir = tmpdir.path().join("dest");
49-
{
50-
std::fs::create_dir_all(&source_dir).unwrap();
51-
std::fs::create_dir_all(&dest_dir).unwrap();
52-
std::fs::File::create(source_dir.join("file.txt")).unwrap();
53-
}
54-
let spec = format!(
55-
"{{git: {:?}}}",
56-
std::env::current_dir()
57-
.unwrap()
58-
.parent()
59-
.unwrap()
60-
.parent()
61-
.unwrap()
62-
);
63-
let source: GitSource = serde_yaml::from_str(&spec).unwrap();
64-
source.collect(&dest_dir).unwrap();
65-
66-
assert!(dest_dir.join(".git").is_dir());
67-
}
44+
// #[rstest]
45+
// fn test_git_sources(tmpdir: tempfile::TempDir) {
46+
// init_logging();
47+
// let source_dir = tmpdir.path().join("source");
48+
// let dest_dir = tmpdir.path().join("dest");
49+
// {
50+
// std::fs::create_dir_all(&source_dir).unwrap();
51+
// std::fs::create_dir_all(&dest_dir).unwrap();
52+
// std::fs::File::create(source_dir.join("file.txt")).unwrap();
53+
// }
54+
// let spec = format!(
55+
// "{{git: {:?}}}",
56+
// std::env::current_dir()
57+
// .unwrap()
58+
// .parent()
59+
// .unwrap()
60+
// .parent()
61+
// .unwrap()
62+
// );
63+
// let source: GitSource = serde_yaml::from_str(&spec).unwrap();
64+
// source.collect(&dest_dir).unwrap();
65+
//
66+
// assert!(dest_dir.join(".git").is_dir());
67+
// }
6868

6969
#[rstest]
7070
fn test_tar_sources(tmpdir: tempfile::TempDir) {

0 commit comments

Comments
 (0)