|
1 | 1 | //! Tests for the `cargo doc` command. |
2 | 2 |
|
3 | | -use cargo::core::compiler::RustDocFingerprint; |
4 | 3 | use cargo_test_support::paths::CargoPathExt; |
5 | 4 | use cargo_test_support::registry::Package; |
6 | 5 | use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project}; |
@@ -1716,179 +1715,3 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..] |
1716 | 1715 | ) |
1717 | 1716 | .run(); |
1718 | 1717 | } |
1719 | | - |
1720 | | -#[cargo_test] |
1721 | | -fn doc_fingerprint_is_versioning_consistent() { |
1722 | | - // Random rustc verbose version |
1723 | | - let old_rustc_verbose_version = format!( |
1724 | | - "\ |
1725 | | -rustc 1.41.1 (f3e1a954d 2020-02-24) |
1726 | | -binary: rustc |
1727 | | -commit-hash: f3e1a954d2ead4e2fc197c7da7d71e6c61bad196 |
1728 | | -commit-date: 2020-02-24 |
1729 | | -host: {} |
1730 | | -release: 1.41.1 |
1731 | | -LLVM version: 9.0 |
1732 | | -", |
1733 | | - rustc_host() |
1734 | | - ); |
1735 | | - |
1736 | | - // Create the dummy project. |
1737 | | - let dummy_project = project() |
1738 | | - .file( |
1739 | | - "Cargo.toml", |
1740 | | - r#" |
1741 | | - [package] |
1742 | | - name = "foo" |
1743 | | - version = "1.2.4" |
1744 | | - authors = [] |
1745 | | - "#, |
1746 | | - ) |
1747 | | - .file("src/lib.rs", "//! These are the docs!") |
1748 | | - .build(); |
1749 | | - |
1750 | | - dummy_project.cargo("doc").run(); |
1751 | | - |
1752 | | - let fingerprint: RustDocFingerprint = |
1753 | | - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) |
1754 | | - .expect("JSON Serde fail"); |
1755 | | - |
1756 | | - // Check that the fingerprint contains the actual rustc version |
1757 | | - // which has been used to compile the docs. |
1758 | | - let output = std::process::Command::new("rustc") |
1759 | | - .arg("-vV") |
1760 | | - .output() |
1761 | | - .expect("Failed to get actual rustc verbose version"); |
1762 | | - assert_eq!( |
1763 | | - fingerprint.rustc_vv, |
1764 | | - (String::from_utf8_lossy(&output.stdout).as_ref()) |
1765 | | - ); |
1766 | | - |
1767 | | - // As the test shows above. Now we have generated the `doc/` folder and inside |
1768 | | - // the rustdoc fingerprint file is located with the correct rustc version. |
1769 | | - // So we will remove it and create a new fingerprint with an old rustc version |
1770 | | - // inside it. We will also place a bogus file inside of the `doc/` folder to ensure |
1771 | | - // it gets removed as we expect on the next doc compilation. |
1772 | | - dummy_project.change_file( |
1773 | | - "target/.rustdoc_fingerprint.json", |
1774 | | - &old_rustc_verbose_version, |
1775 | | - ); |
1776 | | - |
1777 | | - fs::write( |
1778 | | - dummy_project.build_dir().join("doc/bogus_file"), |
1779 | | - String::from("This is a bogus file and should be removed!"), |
1780 | | - ) |
1781 | | - .expect("Error writing test bogus file"); |
1782 | | - |
1783 | | - // Now if we trigger another compilation, since the fingerprint contains an old version |
1784 | | - // of rustc, cargo should remove the entire `/doc` folder (including the fingerprint) |
1785 | | - // and generating another one with the actual version. |
1786 | | - // It should also remove the bogus file we created above. |
1787 | | - dummy_project.cargo("doc").run(); |
1788 | | - |
1789 | | - assert!(!dummy_project.build_dir().join("doc/bogus_file").exists()); |
1790 | | - |
1791 | | - let fingerprint: RustDocFingerprint = |
1792 | | - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) |
1793 | | - .expect("JSON Serde fail"); |
1794 | | - |
1795 | | - // Check that the fingerprint contains the actual rustc version |
1796 | | - // which has been used to compile the docs. |
1797 | | - assert_eq!( |
1798 | | - fingerprint.rustc_vv, |
1799 | | - (String::from_utf8_lossy(&output.stdout).as_ref()) |
1800 | | - ); |
1801 | | -} |
1802 | | - |
1803 | | -#[cfg(target_os = "linux")] |
1804 | | -#[cargo_test] |
1805 | | -fn doc_fingerprint_respects_target_paths() { |
1806 | | - // Random rustc verbose version |
1807 | | - let old_rustc_verbose_version = format!( |
1808 | | - "\ |
1809 | | -rustc 1.41.1 (f3e1a954d 2020-02-24) |
1810 | | -binary: rustc |
1811 | | -commit-hash: f3e1a954d2ead4e2fc197c7da7d71e6c61bad196 |
1812 | | -commit-date: 2020-02-24 |
1813 | | -host: {} |
1814 | | -release: 1.41.1 |
1815 | | -LLVM version: 9.0 |
1816 | | -", |
1817 | | - rustc_host() |
1818 | | - ); |
1819 | | - |
1820 | | - // Create the dummy project. |
1821 | | - let dummy_project = project() |
1822 | | - .file( |
1823 | | - "Cargo.toml", |
1824 | | - r#" |
1825 | | - [package] |
1826 | | - name = "foo" |
1827 | | - version = "1.2.4" |
1828 | | - authors = [] |
1829 | | - "#, |
1830 | | - ) |
1831 | | - .file("src/lib.rs", "//! These are the docs!") |
1832 | | - .build(); |
1833 | | - |
1834 | | - dummy_project |
1835 | | - .cargo("doc --target x86_64-unknown-linux-gnu") |
1836 | | - .run(); |
1837 | | - |
1838 | | - let fingerprint: RustDocFingerprint = |
1839 | | - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) |
1840 | | - .expect("JSON Serde fail"); |
1841 | | - |
1842 | | - // Check that the fingerprint contains the actual rustc version |
1843 | | - // which has been used to compile the docs. |
1844 | | - let output = std::process::Command::new("rustc") |
1845 | | - .arg("-vV") |
1846 | | - .output() |
1847 | | - .expect("Failed to get actual rustc verbose version"); |
1848 | | - assert_eq!( |
1849 | | - fingerprint.rustc_vv, |
1850 | | - (String::from_utf8_lossy(&output.stdout).as_ref()) |
1851 | | - ); |
1852 | | - |
1853 | | - // As the test shows above. Now we have generated the `doc/` folder and inside |
1854 | | - // the rustdoc fingerprint file is located with the correct rustc version. |
1855 | | - // So we will remove it and create a new fingerprint with an old rustc version |
1856 | | - // inside it. We will also place a bogus file inside of the `doc/` folder to ensure |
1857 | | - // it gets removed as we expect on the next doc compilation. |
1858 | | - dummy_project.change_file( |
1859 | | - "target/.rustdoc_fingerprint.json", |
1860 | | - &old_rustc_verbose_version, |
1861 | | - ); |
1862 | | - |
1863 | | - fs::write( |
1864 | | - dummy_project |
1865 | | - .build_dir() |
1866 | | - .join("x86_64-unknown-linux-gnu/doc/bogus_file"), |
1867 | | - String::from("This is a bogus file and should be removed!"), |
1868 | | - ) |
1869 | | - .expect("Error writing test bogus file"); |
1870 | | - |
1871 | | - // Now if we trigger another compilation, since the fingerprint contains an old version |
1872 | | - // of rustc, cargo should remove the entire `/doc` folder (including the fingerprint) |
1873 | | - // and generating another one with the actual version. |
1874 | | - // It should also remove the bogus file we created above. |
1875 | | - dummy_project |
1876 | | - .cargo("doc --target x86_64-unknown-linux-gnu") |
1877 | | - .run(); |
1878 | | - |
1879 | | - assert!(!dummy_project |
1880 | | - .build_dir() |
1881 | | - .join("x86_64-unknown-linux-gnu/doc/bogus_file") |
1882 | | - .exists()); |
1883 | | - |
1884 | | - let fingerprint: RustDocFingerprint = |
1885 | | - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) |
1886 | | - .expect("JSON Serde fail"); |
1887 | | - |
1888 | | - // Check that the fingerprint contains the actual rustc version |
1889 | | - // which has been used to compile the docs. |
1890 | | - assert_eq!( |
1891 | | - fingerprint.rustc_vv, |
1892 | | - (String::from_utf8_lossy(&output.stdout).as_ref()) |
1893 | | - ); |
1894 | | -} |
0 commit comments