@@ -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]
0 commit comments