Skip to content

Commit add168f

Browse files
committed
fix .NET in GitHub actions
1 parent dde445a commit add168f

File tree

6 files changed

+26
-66
lines changed

6 files changed

+26
-66
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ jobs:
3434
with:
3535
components: clippy
3636

37-
- name: ⚡ Cache
38-
uses: actions/cache@v4
39-
with:
40-
path: |
41-
~/.cargo/registry
42-
~/.cargo/git
43-
target
44-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
45-
4637
- name: Clippy
4738
uses: actions-rs/clippy-check@v1
4839
with:
@@ -68,18 +59,19 @@ jobs:
6859

6960
- name: Setup .NET
7061
uses: actions/setup-dotnet@v5
71-
if: ${{ matrix.os == 'ubuntu-latest' }}
7262
with:
7363
dotnet-version: '8.x.x'
7464

65+
- name: Install dotnet-script
66+
run: |
67+
dotnet tool install --global dotnet-script
68+
echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
69+
7570
- name: Setup Deno
7671
uses: denoland/setup-deno@v1
7772
with:
7873
deno-version: v1.x
7974

80-
- name: Cache
81-
uses: Swatinem/rust-cache@v2
82-
8375
- name: Build and run tests
8476
run: env PCRE2_SYS_STATIC=1 cargo test
8577

pomsky-lib/afl-fuzz/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The latter requirement is tested by compiling the regex with the respective rege
77
- deno (for JavaScript)
88
- javac
99
- python
10-
- mcs (for .NET)
10+
- dotnet-script (for .NET)
1111

1212
## Usage
1313

pomsky-lib/tests/it/files.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ impl Options {
118118

119119
fn can_compile_regex(flavor: RegexFlavor) -> bool {
120120
use RegexFlavor::*;
121-
#[cfg(target_os = "linux")]
122-
if flavor == DotNet {
123-
return true;
124-
}
125-
matches!(flavor, Rust | Pcre | Ruby | JavaScript | Java | Python)
121+
matches!(flavor, Rust | Pcre | Ruby | JavaScript | Java | Python | DotNet)
126122
}
127123

128124
#[derive(Clone, Copy, Debug)]
@@ -227,7 +223,6 @@ pub(crate) fn test_file(
227223
RegexFlavor::JavaScript => proc.test_js(regex),
228224
RegexFlavor::Java => proc.test_java(regex),
229225
RegexFlavor::Python => proc.test_python(regex),
230-
#[cfg(target_os = "linux")]
231226
RegexFlavor::DotNet => proc.test_dotnet(regex),
232227
_ => {
233228
eprintln!(

pomsky-lib/tests/it/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ fn defer_main() {
125125
eprintln!(" Ruby was invoked {} times", rt.ruby.get_count());
126126
eprintln!(" Rust was invoked {} times", rt.rust.get_count());
127127
eprintln!(" PCRE was invoked {} times", rt.pcre.get_count());
128-
129-
#[cfg(target_os = "linux")]
130128
eprintln!(" .NET was invoked {} times", rt.dotnet.get_count());
131129
}
132130

regex-test/dotnet/TesterAsync.cs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
using System;
22
using System.Text.RegularExpressions;
33

4-
public class TesterAsync {
5-
public static void Main(string[] args) {
6-
string line;
7-
string testLine;
4+
string line;
5+
string testLine;
86

9-
while ((line = Console.ReadLine()) != null) {
10-
if (!line.StartsWith("REGEX:")) {
11-
continue;
12-
}
7+
while ((line = Console.ReadLine()) != null) {
8+
if (!line.StartsWith("REGEX:")) {
9+
continue;
10+
}
1311

14-
try {
15-
var r = new Regex(line.Substring(6), RegexOptions.Compiled);
16-
Console.WriteLine("success");
12+
try {
13+
var r = new Regex(line.Substring(6), RegexOptions.Compiled);
14+
Console.WriteLine("success");
1715

18-
while ((testLine = Console.ReadLine()) != null && testLine.StartsWith("TEST:")) {
19-
var test = testLine.Substring(5);
20-
if (r.IsMatch(test)) {
21-
Console.WriteLine("test good");
22-
} else {
23-
throw new ArgumentException($"Regex '{r}' does not match '{test}'");
24-
}
25-
}
26-
} catch (ArgumentException e) {
27-
string message = e.Message.Replace("\\", @"\\").Replace("\n", @"\n");
28-
Console.WriteLine(message);
16+
while ((testLine = Console.ReadLine()) != null && testLine.StartsWith("TEST:")) {
17+
var test = testLine.Substring(5);
18+
if (r.IsMatch(test)) {
19+
Console.WriteLine("test good");
20+
} else {
21+
throw new ArgumentException($"Regex '{r}' does not match '{test}'");
2922
}
3023
}
24+
} catch (ArgumentException e) {
25+
string message = e.Message.Replace("\\", @"\\").Replace("\n", @"\n");
26+
Console.WriteLine(message);
3127
}
3228
}

regex-test/src/sync/mod.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub struct RegexTest {
1212
pub js: Process,
1313
pub java: Process,
1414
pub py: Process,
15-
#[cfg(target_os = "linux")]
1615
pub dotnet: Process,
1716
pub rust: Count,
1817
pub pcre: Count,
@@ -29,23 +28,18 @@ impl RegexTest {
2928
scope.spawn(|| self.test_js("x"));
3029
scope.spawn(|| self.test_java("x"));
3130
scope.spawn(|| self.test_python("x"));
32-
33-
#[cfg(target_os = "linux")]
3431
scope.spawn(|| self.test_dotnet("x"));
3532
});
3633
self.js.reset_count();
3734
self.java.reset_count();
3835
self.py.reset_count();
39-
40-
#[cfg(target_os = "linux")]
4136
self.dotnet.reset_count();
4237
}
4338

4439
pub fn kill_processes(&self) -> io::Result<()> {
4540
self.js.kill()?;
4641
self.py.kill()?;
4742
self.java.kill()?;
48-
#[cfg(target_os = "linux")]
4943
self.dotnet.kill()?;
5044
Ok(())
5145
}
@@ -118,27 +112,12 @@ impl RegexTest {
118112
self.java.test(regex, tests)
119113
}
120114

121-
#[cfg(target_os = "linux")]
122115
pub fn test_dotnet(&self, regex: impl AsRef<str>) -> Outcome {
123116
self.test_dotnet_with(regex, &[] as &[&str])
124117
}
125118

126-
#[cfg(target_os = "linux")]
127119
pub fn test_dotnet_with(&self, regex: impl AsRef<str>, tests: &[impl AsRef<str>]) -> Outcome {
128-
self.dotnet.start_with("dotnet", "mono", &["TesterAsync.exe"], || {
129-
let compiled = concat!(env!("CARGO_MANIFEST_DIR"), "/dotnet/TesterAsync.exe");
130-
if !Path::new(compiled).exists() {
131-
let result = Command::new("mcs")
132-
.current_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/dotnet"))
133-
.arg("TesterAsync.cs")
134-
.output()
135-
.expect(
136-
"`mcs` executable not found, required for running .NET regex flavor tests",
137-
);
138-
assert!(result.status.success(), "Could not compile C# file");
139-
}
140-
});
141-
120+
self.dotnet.start("dotnet", "dotnet-script", &["TesterAsync.cs"]);
142121
self.dotnet.test(regex, tests)
143122
}
144123
}

0 commit comments

Comments
 (0)