build.rs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // This test must be run in release mode or it will stack overflow.
  2. mod test {
  3. use tempfile::TempDir;
  4. use tracing::{debug, info};
  5. #[ignore = "Skipping because test is too slow and CI should already self host hoonc from scratch"]
  6. #[tokio::test]
  7. async fn test_compile_test_app() -> Result<(), Box<dyn std::error::Error>> {
  8. let temp_dir = TempDir::new()?;
  9. let temp_path = temp_dir.path();
  10. let out_path = format!(
  11. "{}/out.jam",
  12. hoonc::canonicalize_and_string(temp_path).to_lowercase()
  13. );
  14. // use std::path to get pwd() and then canonicalize
  15. let pwd = std::env::current_dir()?;
  16. let mut test_dir = pwd.clone();
  17. test_dir.pop();
  18. test_dir.push("test-app");
  19. let entry = test_dir.join("bootstrap/kernel.hoon");
  20. // TODO: Add -o flag to specify output file and then use the tmp-dir
  21. // TODO: instead of mutating the non-tmp filesystem in this test
  22. // Clean up any existing output file
  23. let _ = tokio::fs::remove_file(out_path).await;
  24. let mut deps_dir = pwd.clone();
  25. deps_dir.pop();
  26. deps_dir.push("hoon-deps");
  27. info!("Test directory: {:?}", test_dir);
  28. info!("Dependencies directory: {:?}", deps_dir);
  29. info!("Entry file: {:?}", entry);
  30. let (nockapp, out_path) =
  31. hoonc::initialize_with_default_cli(entry, deps_dir, None, false, true).await?;
  32. let result = hoonc::run_build(nockapp, Some(out_path.clone())).await;
  33. assert!(result.is_ok());
  34. // Cleanup
  35. let _ = tokio::fs::remove_file(out_path.clone()).await;
  36. debug!("Removed file");
  37. // Second run to test consecutive execution
  38. // FIXME: This currently panics because of the one-shot.
  39. // let result = test_build(&mut nockapp).await;
  40. // // Cleanup
  41. // let _ = fs::remove_file("out.jam").await;
  42. Ok(())
  43. }
  44. }