Repository navigation
feat(module): share cross-platform module test support #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ef028ec
906d0d4
08114eb
644d646
d1f05a8
5e509c9
c56d6f0
a30906e
75c645a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -664,7 +664,25 @@ impl ModuleHost { | |||||||||||||||||
| /// Refusals are returned per artifact so one bad file cannot prevent the | ||||||||||||||||||
| /// remaining modules from loading. | ||||||||||||||||||
| pub fn load_dir(&self, directory: impl AsRef<Path>) -> Result<Vec<Result<ModuleInfo>>> { | ||||||||||||||||||
| let directory = directory.as_ref(); | ||||||||||||||||||
| self.load_dir_inner(directory.as_ref(), None) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /// Load modules from a directory while requiring each discovered manifest | ||||||||||||||||||
| /// to declare `expected_name` before it can be registered with the host. | ||||||||||||||||||
| #[cfg(feature = "test-support")] | ||||||||||||||||||
| pub(crate) fn load_dir_expected( | ||||||||||||||||||
| &self, | ||||||||||||||||||
| directory: impl AsRef<Path>, | ||||||||||||||||||
| expected_name: &str, | ||||||||||||||||||
| ) -> Result<Vec<Result<ModuleInfo>>> { | ||||||||||||||||||
| self.load_dir_inner(directory.as_ref(), Some(expected_name)) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| fn load_dir_inner( | ||||||||||||||||||
| &self, | ||||||||||||||||||
| directory: &Path, | ||||||||||||||||||
| expected_name: Option<&str>, | ||||||||||||||||||
| ) -> Result<Vec<Result<ModuleInfo>>> { | ||||||||||||||||||
| check_directory(directory)?; | ||||||||||||||||||
| let mut directories = self | ||||||||||||||||||
| .inner | ||||||||||||||||||
|
|
@@ -702,6 +720,16 @@ impl ModuleHost { | |||||||||||||||||
| } | ||||||||||||||||||
| }); | ||||||||||||||||||
| match inspected { | ||||||||||||||||||
| Ok(module) | ||||||||||||||||||
| if expected_name.is_some_and(|expected| { | ||||||||||||||||||
| sanitize_untrusted(&module.manifest().module.name) != expected | ||||||||||||||||||
| }) => | ||||||||||||||||||
|
Comment on lines
+723
to
+726
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compare the manifest name without sanitizing it
Suggested change
[RULE] exact-identity-comparison · |
||||||||||||||||||
| { | ||||||||||||||||||
| outcomes.push(Err(Error::module_refused( | ||||||||||||||||||
| &path, | ||||||||||||||||||
| "module name does not match expected test identity", | ||||||||||||||||||
| ))); | ||||||||||||||||||
| } | ||||||||||||||||||
| Ok(module) => pending.push((path, module)), | ||||||||||||||||||
| Err(error) => outcomes.push(Err(error)), | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Windows
modulesmatrix, this step runs before the later PowerShell block creates a private directory and redirectsTEMP/TMP. The testa_rejected_library_consumes_the_loader_attemptcallsload_dir_expectedon a stagedTempDir, while the existing Windows loader tests document that GitHub runners' default temp directories inherit an ACE rejected bycheck_directory; that outer placement error releases the reservation, so the subsequent assertion that it isMODULE_LOAD_CONSUMEDfails and breaks this matrix job.Useful? React with 👍 / 👎.