nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ashleygwilliams/wasm-pack
Pull request #5 (2018-02-20 23:20:00)

feat(pkg): do it in a dir


Patch:
diff --git a/.gitignore b/.gitignore
index b7e9ede..dc080d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
 
 /target
 **/*.rs.bk
-package.json
+/pkg
diff --git a/src/lib.rs b/src/lib.rs
index 9e5aa7b..29a5e8c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,6 +4,7 @@ extern crate serde_derive;
 extern crate serde_json;
 extern crate toml;
 
+use std::fs;
 use std::fs::File;
 use std::io::prelude::*;
 
@@ -46,8 +47,14 @@ impl CargoManifest {
     }
 }
 
+fn create_pkg_dir() -> Result<(), Error> {
+    fs::create_dir_all("./pkg")?;
+    Ok(())
+}
+
 pub fn write_package_json() -> Result<(), Error> {
-    let mut pkg_file = File::create("package.json")?;
+    create_pkg_dir()?;
+    let mut pkg_file = File::create("./pkg/package.json")?;
     let crate_data = read_cargo_toml()?;
     let npm_data = crate_data.into_npm();
     let npm_json = serde_json::to_string(&npm_data)?;


Test patch:
diff --git a/tests/wasm-pack.rs b/tests/wasm-pack.rs
index 8093d18..5f9120d 100644
--- a/tests/wasm-pack.rs
+++ b/tests/wasm-pack.rs
@@ -5,5 +5,5 @@ use std::fs;
 #[test]
 fn it_creates_a_package_json() {
     assert!(wasm_pack::write_package_json().is_ok());
-    assert!(fs::metadata("./package.json").is_ok());
+    assert!(fs::metadata("./pkg/package.json").is_ok());
 }
Repository: ashleygwilliams/wasm-pack
Pull request #167 (2018-06-12 01:21:30)

Robertohuertasm feature wasm bindgen detection
cargo fmt got sad about the fmt of my merge (i was lazy and did it in the web UI).


Patch:
diff --git a/src/command.rs b/src/command.rs
index 21c552a..bcdcc99 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -176,6 +176,10 @@ fn init(
 
     let crate_path = set_crate_path(path);
 
+    info!(&log, "Checking wasm-bindgen dependency...");
+    manifest::check_wasm_bindgen(&crate_path)?;
+    info!(&log, "wasm-bindgen dependency is correctly declared.");
+
     info!(&log, "Adding wasm-target...");
     build::rustup_add_wasm_target()?;
     info!(&log, "Adding wasm-target was successful.");
diff --git a/src/manifest.rs b/src/manifest.rs
index 297e995..872924e 100644
--- a/src/manifest.rs
+++ b/src/manifest.rs
@@ -11,6 +11,7 @@ use PBAR;
 #[derive(Deserialize)]
 struct CargoManifest {
     package: CargoPackage,
+    dependencies: Option<CargoDependencies>,
     lib: Option<CargoLib>,
 }
 
@@ -24,6 +25,12 @@ struct CargoPackage {
     repository: Option<String>,
 }
 
+#[derive(Deserialize)]
+struct CargoDependencies {
+    #[serde(rename = "wasm-bindgen")]
+    wasm_bindgen: Option<String>,
+}
+
 #[derive(Deserialize)]
 struct CargoLib {
     #[serde(rename = "crate-type")]
@@ -144,6 +151,18 @@ pub fn get_crate_name(path: &str) -> Result<String, Error> {
     Ok(read_cargo_toml(path)?.package.name)
 }
 
+pub fn check_wasm_bindgen(path: &str) -> Result<(), Error> {
+    if read_cargo_toml(path)?.dependencies.map_or(false, |x| {
+        !x.wasm_bindgen.unwrap_or("".to_string()).is_empty()
+    }) {
+        return Ok(());
+    }
+    Error::crate_config(&format!(
+        "Ensure that you have \"{}\" as a dependency in your Cargo.toml file:\n[dependencies]\nwasm-bindgen = \"0.2\"",
+        style("wasm-bindgen").bold().dim()
+    ))
+}
+
 fn has_cdylib(path: &str) -> Result<bool, Error> {
     Ok(read_cargo_toml(path)?.lib.map_or(false, |lib| {
         lib.crate_type


Test patch:
diff --git a/tests/fixtures/bad-cargo-toml/Cargo.toml b/tests/fixtures/bad-cargo-toml/Cargo.toml
index c73a430..1c8e304 100644
--- a/tests/fixtures/bad-cargo-toml/Cargo.toml
+++ b/tests/fixtures/bad-cargo-toml/Cargo.toml
@@ -7,4 +7,3 @@ authors = ["Michael Gattozzi <mgattozzi@gmail.com>"]
 crate-type = ["foo"]
 
 [dependencies]
-wasm-bindgen = "0.2"
diff --git a/tests/manifest/main.rs b/tests/manifest/main.rs
index dc2183c..cf15438 100644
--- a/tests/manifest/main.rs
+++ b/tests/manifest/main.rs
@@ -84,3 +84,13 @@ fn it_creates_a_package_json_provided_path_with_scope() {
     let pkg = utils::read_package_json(&path).unwrap();
     assert_eq!(pkg.name, "@test/scopes-hello-world");
 }
+
+#[test]
+fn it_errors_when_wasm_bindgen_is_not_declared() {
+    assert!(manifest::check_wasm_bindgen("tests/fixtures/bad-cargo-toml").is_err());
+}
+
+#[test]
+fn it_does_not_error_when_wasm_bindgen_is_declared() {
+    assert!(manifest::check_wasm_bindgen("tests/fixtures/js-hello-world").is_ok());
+}
Repository: scionproto/scion
Pull request #3431 (2019-11-27 07:59:11)

SIG acceptance tests: Make sure that config is reloaded


<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3431)
<!-- Reviewable:end -->



Patch:
diff --git a/acceptance/sigutil/common.sh b/acceptance/sigutil/common.sh
index 375377d91..205ec23d3 100755
--- a/acceptance/sigutil/common.sh
+++ b/acceptance/sigutil/common.sh
@@ -52,4 +52,10 @@ reload_sig() {
     ./tools/dc scion exec -T scion_sig_"$1" kill -SIGHUP "$id"
     # Wait till the new config takes effect.
     sleep 3
+    # Make sure that the reload actually happened.
+    COUNT=$(grep --text ".*Config reloaded.*" "logs/sig$1.log" | wc -l)
+    if [ "$COUNT" != "$2" ]; then
+            echo "Expected $2 config reloads, found $COUNT."
+        exit 1
+    fi
 }


Test patch:
diff --git a/acceptance/sig_reload_acceptance/test b/acceptance/sig_reload_acceptance/test
index b9797cd40..8d3891a6b 100755
--- a/acceptance/sig_reload_acceptance/test
+++ b/acceptance/sig_reload_acceptance/test
@@ -16,12 +16,12 @@ test_run() {
     # Remove $DST_IA from sig.json
     HOP_JSON=$(jq -c ".ASes.\"$DST_IA\"" $SIG_JSON)
     jq "del(.ASes.\"$DST_IA\")" $SIG_JSON | sponge $SIG_JSON
-    reload_sig "$SRC_IA_FILE"
+    reload_sig "$SRC_IA_FILE" 2
     # Must fail
     ./bin/sig_ping_acceptance -d -src $SRC_IA -dst $DST_IA || [ $? -eq 1 ]
     # Add $DST_IA again to sig.json
     jq ".ASes.\"$DST_IA\" = $HOP_JSON" $SIG_JSON | sponge $SIG_JSON
-    reload_sig "$SRC_IA_FILE"
+    reload_sig "$SRC_IA_FILE" 3
     # should work again
     ./bin/sig_ping_acceptance -attempts 1 -d -log.console info -src $SRC_IA -dst $DST_IA
 }
Repository: scionproto/scion
Pull request #3502 (2019-12-09 17:10:56)

Acceptance: Fix sig reload test
This change reduces the logging interval to one second.
Before, the interval was 5 seconds with a sleep of 3 seconds when
checking the logs for some lines. This leads to a lot of unnecessary
flakiness.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3502)
<!-- Reviewable:end -->



Patch:
diff --git a/acceptance/sigutil/common.sh b/acceptance/sigutil/common.sh
index 205ec23d3..31d64fc87 100755
--- a/acceptance/sigutil/common.sh
+++ b/acceptance/sigutil/common.sh
@@ -9,6 +9,9 @@ DST_IA=${DST_IA:-1-ff00:0:112}
 test_setup() {
     set -e
     ./scion.sh topology nobuild -c $TEST_TOPOLOGY -d -t --sig -n 242.254.0.0/16
+    for sig in gen/ISD1/*/sig*/sig.toml; do
+        sed -i '/\[logging\.file\]/a FlushInterval = 1' "$sig"
+    done
     ./scion.sh run nobuild
     ./tools/dc start 'tester*'
     sleep 7
@@ -24,7 +27,7 @@ print_help() {
 	        execute only the setup phase.
 	    $PROGRAM run
 	        execute only the run phase.
-	    $PROGRAM teardown 
+	    $PROGRAM teardown
 	        execute only the teardown phase.
 	_EOF
 }
diff --git a/go/acceptance/sig_ping_acceptance/main.go b/go/acceptance/sig_ping_acceptance/main.go
index 26be2ff0c..a24987ea6 100644
--- a/go/acceptance/sig_ping_acceptance/main.go
+++ b/go/acceptance/sig_ping_acceptance/main.go
@@ -33,6 +33,7 @@ var (
 	name     = "sig_ping_acceptance"
 	cmd      = "ping"
 	attempts = flag.Int("attempts", 5, "Number of ping attempts.")
+	fail     = flag.Bool("fail", false, "Succeed if the pings don't make it through.")
 )
 
 func main() {
@@ -58,9 +59,17 @@ func realMain() int {
 	in := integration.NewBinaryIntegration(name, integration.WrapperCmd, args, nil)
 	err := integration.RunUnaryTests(in, integration.UniqueIAPairs(acceptance.SigAddr),
 		time.Duration(*attempts)*time.Second+integration.DefaultRunTimeout)
-	if err != nil {
+	if !*fail && err != nil {
+		// The pings were supposed to get through but they didn't.
 		fmt.Fprintf(os.Stderr, "Failed to run tests: %s\n", err)
 		return 1
+
+	}
+	if *fail && err == nil {
+		fmt.Fprintf(os.Stderr, "Failed to run tests: "+
+			"Pings were supposed to not to reach the destination but they did.\n")
+		return 1
+
 	}
 	return 0
 }


Test patch:
diff --git a/acceptance/sig_reload_acceptance/test b/acceptance/sig_reload_acceptance/test
index 8d3891a6b..dbd3a01dc 100755
--- a/acceptance/sig_reload_acceptance/test
+++ b/acceptance/sig_reload_acceptance/test
@@ -18,7 +18,7 @@ test_run() {
     jq "del(.ASes.\"$DST_IA\")" $SIG_JSON | sponge $SIG_JSON
     reload_sig "$SRC_IA_FILE" 2
     # Must fail
-    ./bin/sig_ping_acceptance -d -src $SRC_IA -dst $DST_IA || [ $? -eq 1 ]
+    ./bin/sig_ping_acceptance -d -fail -src $SRC_IA -dst $DST_IA
     # Add $DST_IA again to sig.json
     jq ".ASes.\"$DST_IA\" = $HOP_JSON" $SIG_JSON | sponge $SIG_JSON
     reload_sig "$SRC_IA_FILE" 3
Repository: scionproto/scion
Pull request #3565 (2020-01-03 13:45:24)

python: Fix YAMLLoadWarning


<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3565)
<!-- Reviewable:end -->



Patch:
diff --git a/python/lib/util.py b/python/lib/util.py
index 30699c261..3ad39c765 100644
--- a/python/lib/util.py
+++ b/python/lib/util.py
@@ -100,7 +100,7 @@ def load_yaml_file(file_path):
     """
     try:
         with open(file_path) as f:
-            return yaml.load(f)
+            return yaml.load(f, Loader=yaml.SafeLoader)
     except OSError as e:
         raise SCIONIOError("Error opening '%s': %s" %
                            (file_path, e.strerror)) from None


Test patch:
diff --git a/python/test/lib/util_test.py b/python/test/lib/util_test.py
index 0fb690444..3d6f329da 100644
--- a/python/test/lib/util_test.py
+++ b/python/test/lib/util_test.py
@@ -102,13 +102,6 @@ class Loader(object):
     """
     Helper class for load_yaml_file tests.
     """
-    def _basic(self, target, loader):
-        loader.return_value = "loader dict"
-        with patch.object(builtins, 'open', mock_open()) as open_:
-            ntools.eq_(target("File_Path"), "loader dict")
-            open_.assert_called_once_with("File_Path")
-            loader.assert_called_once_with(open_.return_value)
-
     @patch.object(builtins, 'open', mock_open())
     def _file_error(self, target):
         builtins.open.side_effect = IsADirectoryError
@@ -125,10 +118,6 @@ class TestLoadYAMLFile(Loader):
     """
     Unit tests for lib.util.load_yaml_file
     """
-    @patch("lib.util.yaml.load", autospec=True)
-    def test_basic(self, loader):
-        self._basic(load_yaml_file, loader)
-
     def test_file_error(self):
         self._file_error(load_yaml_file)